From: Paul Cruz Date: Mon, 14 Aug 2017 16:41:04 +0000 (-0700) Subject: added error checking for dictionary initialized with null src X-Git-Tag: v1.3.1^2~11^2^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38f4e433814158dde6039317188793d637e29310;p=thirdparty%2Fzstd.git added error checking for dictionary initialized with null src --- diff --git a/doc/educational_decoder/zstd_decompress.c b/doc/educational_decoder/zstd_decompress.c index e22df1c10..961d27a5b 100644 --- a/doc/educational_decoder/zstd_decompress.c +++ b/doc/educational_decoder/zstd_decompress.c @@ -1404,6 +1404,7 @@ size_t ZSTD_get_decompressed_size(const void *src, const size_t src_len) { /******* DICTIONARY PARSING ***************************************************/ #define DICT_SIZE_ERROR() ERROR("Dictionary size cannot be less than 8 bytes") +#define NULL_SRC() ERROR("Tried to create dictionary with pointer to null src"); dictionary_t* create_dictionary() { dictionary_t* dict = calloc(1, sizeof(dictionary_t)); @@ -1420,6 +1421,9 @@ void parse_dictionary(dictionary_t *const dict, const void *src, size_t src_len) { const u8 *byte_src = (const u8 *)src; memset(dict, 0, sizeof(dictionary_t)); + if (src == NULL) { /* cannot initialize dictionary with null src */ + NULL_SRC(); + } if (src_len < 8) { DICT_SIZE_ERROR(); }