]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
prevent possible segfault when creating seek table 4201/head
authorRobert Rose <robert.rose@mailbox.org>
Sun, 24 Nov 2024 22:36:53 +0000 (23:36 +0100)
committerRobert Rose <robert.rose@mailbox.org>
Mon, 25 Nov 2024 07:57:25 +0000 (08:57 +0100)
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.

contrib/seekable_format/zstdseek_decompress.c

index 4fefc5f2eb6772b59d657f242b5ad6e8d496973a..5ee6e0541a57a91249632991d51b36f891fa4189 100644 (file)
@@ -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;