Skip to content

Commit

Permalink
Fix a nullptr dereference in ZSTD_createCDict_advanced2()
Browse files Browse the repository at this point in the history
If the relevant allocation returns NULL, ZSTD_createCDict_advanced_internal()
will return NULL. But ZSTD_createCDict_advanced2() doesn't check for
this and attempts to use the returned pointer anyway, which leads to
a segfault.
  • Loading branch information
michoecho committed Dec 16, 2023
1 parent 86ead9f commit 9a3b17c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress/zstd_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -5525,7 +5525,7 @@ ZSTD_CDict* ZSTD_createCDict_advanced2(
cctxParams.useRowMatchFinder, cctxParams.enableDedicatedDictSearch,
customMem);

if (ZSTD_isError( ZSTD_initCDict_internal(cdict,
if (!cdict || ZSTD_isError( ZSTD_initCDict_internal(cdict,
dict, dictSize,
dictLoadMethod, dictContentType,
cctxParams) )) {
Expand Down

0 comments on commit 9a3b17c

Please sign in to comment.