diff options
Diffstat (limited to 'src/lib/ndpi_utils.c')
-rw-r--r-- | src/lib/ndpi_utils.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c index 3314cbea2..a9f8d0a7c 100644 --- a/src/lib/ndpi_utils.c +++ b/src/lib/ndpi_utils.c @@ -2320,7 +2320,7 @@ int ndpi_hash_find_entry(ndpi_str_hash *h, char *key, u_int key_len, u_int16_t * int ndpi_hash_add_entry(ndpi_str_hash **h, char *key, u_int8_t key_len, u_int16_t value) { ndpi_str_hash_priv *h_priv = (ndpi_str_hash_priv *)*h; - ndpi_str_hash_priv *item; + ndpi_str_hash_priv *item, *ret_found; if(!key || key_len == 0) return(3); @@ -2350,6 +2350,13 @@ int ndpi_hash_add_entry(ndpi_str_hash **h, char *key, u_int8_t key_len, u_int16_ HASH_ADD(hh, *((ndpi_str_hash_priv **)h), key[0], key_len, item); + HASH_FIND(hh, *((ndpi_str_hash_priv **)h), key, key_len, ret_found); + if(ret_found == NULL) { /* The insertion failed (because of a memory allocation error) */ + ndpi_free(item->key); + ndpi_free(item); + return 4; + } + return 0; } |