From: Robert Rose Date: Sun, 24 Nov 2024 22:36:53 +0000 (+0100) Subject: prevent possible segfault when creating seek table X-Git-Tag: v1.5.7^2~59^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b683c0dbe278f71e371376847deebd44fdcf392f;p=thirdparty%2Fzstd.git prevent possible segfault when creating seek table Add a check whether the seek table of a `ZSTD_seekable` is initialized before creating a new seek table from it. Return `NULL`, if the check fails. --- diff --git a/contrib/seekable_format/zstdseek_decompress.c b/contrib/seekable_format/zstdseek_decompress.c index 4fefc5f2e..5ee6e0541 100644 --- a/contrib/seekable_format/zstdseek_decompress.c +++ b/contrib/seekable_format/zstdseek_decompress.c @@ -252,6 +252,8 @@ size_t ZSTD_seekable_free(ZSTD_seekable* zs) ZSTD_seekTable* ZSTD_seekTable_create_fromSeekable(const ZSTD_seekable* zs) { + assert(zs != NULL); + if (zs->seekTable.entries == NULL) return NULL; ZSTD_seekTable* const st = (ZSTD_seekTable*)malloc(sizeof(ZSTD_seekTable)); if (st==NULL) return NULL;