Skip to content

Commit

Permalink
liblzma: Add NULL checks to LZMA and LZMA2 properties encoders.
Browse files Browse the repository at this point in the history
Previously lzma_lzma_props_encode() and lzma_lzma2_props_encode()
assumed that the options pointers must be non-NULL because the
with these filters the API says it must never be NULL. It is
good to do these checks anyway.
  • Loading branch information
JiaT75 authored and Larhzu committed Feb 6, 2022
1 parent 2523c30 commit 6468f7e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/liblzma/lzma/lzma2_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ lzma_lzma2_encoder_memusage(const void *options)
extern lzma_ret
lzma_lzma2_props_encode(const void *options, uint8_t *out)
{
if (options == NULL)
return LZMA_PROG_ERROR;

const lzma_options_lzma *const opt = options;
uint32_t d = my_max(opt->dict_size, LZMA_DICT_SIZE_MIN);

Expand Down
3 changes: 3 additions & 0 deletions src/liblzma/lzma/lzma_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,9 @@ lzma_lzma_lclppb_encode(const lzma_options_lzma *options, uint8_t *byte)
extern lzma_ret
lzma_lzma_props_encode(const void *options, uint8_t *out)
{
if (options == NULL)
return LZMA_PROG_ERROR;

const lzma_options_lzma *const opt = options;

if (lzma_lzma_lclppb_encode(opt, out))
Expand Down

0 comments on commit 6468f7e

Please sign in to comment.