[PATCH][RFC] lib: zstd: resolve maybe-uninitialized warning

Yegor Yefremov yegorslists at googlemail.com
Wed Jun 14 01:10:25 PDT 2023


On Wed, Jun 14, 2023 at 10:09 AM <yegorslists at googlemail.com> wrote:
>
> From: Yegor Yefremov <yegorslists at googlemail.com>
>
> Perform memset() at the very beginning of the ZSTD_getFrameParams()
> routine.
>
> Signed-off-by: Yegor Yefremov <yegorslists at googlemail.com>
> ---
>  lib/zstd/decompress.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/zstd/decompress.c b/lib/zstd/decompress.c
> index 19bf712881..78df7d660a 100644
> --- a/lib/zstd/decompress.c
> +++ b/lib/zstd/decompress.c
> @@ -207,6 +207,7 @@ static size_t ZSTD_frameHeaderSize(const void *src, size_t srcSize)
>  size_t ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t srcSize)
>  {
>         const BYTE *ip = (const BYTE *)src;
> +       memset(fparamsPtr, 0, sizeof(*fparamsPtr));
>
>         if (srcSize < ZSTD_frameHeaderSize_prefix)
>                 return ZSTD_frameHeaderSize_prefix;
> @@ -214,7 +215,6 @@ size_t ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t
>                 if ((ZSTD_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) {
>                         if (srcSize < ZSTD_skippableHeaderSize)
>                                 return ZSTD_skippableHeaderSize; /* magic number + skippable frame length */
> -                       memset(fparamsPtr, 0, sizeof(*fparamsPtr));
>                         fparamsPtr->frameContentSize = ZSTD_readLE32((const char *)src + 4);
>                         fparamsPtr->windowSize = 0; /* windowSize==0 means a frame is skippable */
>                         return 0;
> --
> 2.34.1

This patch is compile-tested only.

Yegor



More information about the barebox mailing list