diff options
author | jiat75 <jiat0218@gmail.com> | 2022-01-28 20:47:55 +0800 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2022-02-07 00:20:01 +0200 |
commit | 6468f7e41a8e9c611e4ba8d34e2175c5dacdbeb4 (patch) | |
tree | 19d36e4b3824a5c831de500c7a4b1e91d892f88b /src/liblzma | |
parent | liblzma: Fix uint64_t vs. size_t confusion. (diff) | |
download | xz-6468f7e41a8e9c611e4ba8d34e2175c5dacdbeb4.tar.xz |
liblzma: Add NULL checks to LZMA and LZMA2 properties encoders.
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.
Diffstat (limited to 'src/liblzma')
-rw-r--r-- | src/liblzma/lzma/lzma2_encoder.c | 3 | ||||
-rw-r--r-- | src/liblzma/lzma/lzma_encoder.c | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/liblzma/lzma/lzma2_encoder.c b/src/liblzma/lzma/lzma2_encoder.c index 63588ee3..6914f279 100644 --- a/src/liblzma/lzma/lzma2_encoder.c +++ b/src/liblzma/lzma/lzma2_encoder.c @@ -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); diff --git a/src/liblzma/lzma/lzma_encoder.c b/src/liblzma/lzma/lzma_encoder.c index 1f801453..8b90c059 100644 --- a/src/liblzma/lzma/lzma_encoder.c +++ b/src/liblzma/lzma/lzma_encoder.c @@ -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)) |