mesa: Add missing null checks into prog_hash_table.c
authorJuha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Thu, 13 Feb 2014 14:04:23 +0000 (16:04 +0200)
committerTapani Pälli <tapani.palli@intel.com>
Fri, 30 May 2014 06:22:34 +0000 (09:22 +0300)
Check calloc return values in hash_table_insert() and
hash_table_replace()

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/program/prog_hash_table.c

index f45ed46afad455e117a9fc2a68e4311b2d80fb3f..2445d843446fbdcb0845e5c2585ef50e787c19ab 100644 (file)
@@ -142,6 +142,10 @@ hash_table_insert(struct hash_table *ht, void *data, const void *key)
     struct hash_node *node;
 
     node = calloc(1, sizeof(*node));
+    if (node == NULL) {
+       _mesa_error_no_memory(__func__);
+       return;
+    }
 
     node->data = data;
     node->key = key;
@@ -167,6 +171,10 @@ hash_table_replace(struct hash_table *ht, void *data, const void *key)
     }
 
     hn = calloc(1, sizeof(*hn));
+    if (hn == NULL) {
+       _mesa_error_no_memory(__func__);
+       return false;
+    }
 
     hn->data = data;
     hn->key = key;