]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
liblzma: Add NULL checks to LZMA and LZMA2 properties encoders.
authorjiat75 <jiat0218@gmail.com>
Fri, 28 Jan 2022 12:47:55 +0000 (20:47 +0800)
committerLasse Collin <lasse.collin@tukaani.org>
Sun, 6 Feb 2022 22:20:01 +0000 (00:20 +0200)
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.

src/liblzma/lzma/lzma2_encoder.c
src/liblzma/lzma/lzma_encoder.c

index 63588ee30c6b829096b38bba137f974be8387c25..6914f2793b26435027250d62fc391e7cdcbf4668 100644 (file)
@@ -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);
 
index 1f8014539356964ed6a736f20627c4f7763568c2..8b90c0596400134cb20b777a31faf415dc0f6ed8 100644 (file)
@@ -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))