]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
added error checking for dictionary initialized with null src
authorPaul Cruz <paulcruz74@fb.com>
Mon, 14 Aug 2017 16:41:04 +0000 (09:41 -0700)
committerPaul Cruz <paulcruz74@fb.com>
Mon, 14 Aug 2017 16:41:04 +0000 (09:41 -0700)
doc/educational_decoder/zstd_decompress.c

index e22df1c1034e9871a3df7eb644b412b8cf844b09..961d27a5b5669ea8a9883328e9ff1d0ba6ed67c9 100644 (file)
@@ -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();
     }