[Mesa-dev] [PATCH 10/14] mesa: Add missing null checks into prog_hash_table.c
Juha-Pekka Heikkila
juhapekka.heikkila at gmail.com
Wed Mar 26 06:20:44 PDT 2014
Check calloc return values in hash_table_insert() and
hash_table_replace()
Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
---
src/mesa/program/prog_hash_table.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/mesa/program/prog_hash_table.c b/src/mesa/program/prog_hash_table.c
index f45ed46..39ffb7a 100644
--- a/src/mesa/program/prog_hash_table.c
+++ b/src/mesa/program/prog_hash_table.c
@@ -143,6 +143,11 @@ hash_table_insert(struct hash_table *ht, void *data, const void *key)
node = calloc(1, sizeof(*node));
+ if (node == NULL) {
+ _mesa_error_no_memory(__FUNCTION__);
+ return;
+ }
+
node->data = data;
node->key = key;
@@ -168,6 +173,11 @@ hash_table_replace(struct hash_table *ht, void *data, const void *key)
hn = calloc(1, sizeof(*hn));
+ if (hn != NULL) {
+ _mesa_error_no_memory(__FUNCTION__);
+ return false;
+ }
+
hn->data = data;
hn->key = key;
--
1.8.1.2
More information about the mesa-dev
mailing list