Skip to content

Commit

Permalink
prevent possible segfault when creating seek table
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rorosen committed Nov 25, 2024
1 parent b0a179d commit b683c0d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contrib/seekable_format/zstdseek_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit b683c0d

Please sign in to comment.