added error checking for dictionary initialized with null src
This commit is contained in:
parent
7ef9c6f4b2
commit
38f4e43381
@ -1404,6 +1404,7 @@ size_t ZSTD_get_decompressed_size(const void *src, const size_t src_len) {
|
|||||||
|
|
||||||
/******* DICTIONARY PARSING ***************************************************/
|
/******* DICTIONARY PARSING ***************************************************/
|
||||||
#define DICT_SIZE_ERROR() ERROR("Dictionary size cannot be less than 8 bytes")
|
#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* create_dictionary() {
|
||||||
dictionary_t* dict = calloc(1, sizeof(dictionary_t));
|
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) {
|
size_t src_len) {
|
||||||
const u8 *byte_src = (const u8 *)src;
|
const u8 *byte_src = (const u8 *)src;
|
||||||
memset(dict, 0, sizeof(dictionary_t));
|
memset(dict, 0, sizeof(dictionary_t));
|
||||||
|
if (src == NULL) { /* cannot initialize dictionary with null src */
|
||||||
|
NULL_SRC();
|
||||||
|
}
|
||||||
if (src_len < 8) {
|
if (src_len < 8) {
|
||||||
DICT_SIZE_ERROR();
|
DICT_SIZE_ERROR();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user