Check calloc return values in hash_table_insert() and
hash_table_replace()
Signed-off-by: Juha-Pekka Heikkila <[email protected]>
---
src/mesa/program/prog_hash_table.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/mesa/program/prog_hash_table.c
b/src/mesa/program/prog_hash_table.c
index f45ed46..e62ad6f 100644
--- a/src/mesa/program/prog_hash_table.c
+++ b/src/mesa/program/prog_hash_table.c
@@ -143,10 +143,12 @@ hash_table_insert(struct hash_table *ht, void *data,
const void *key)
node = calloc(1, sizeof(*node));
- node->data = data;
- node->key = key;
+ if (node != NULL) {
+ node->data = data;
+ node->key = key;
- insert_at_head(& ht->buckets[bucket], & node->link);
+ insert_at_head(& ht->buckets[bucket], & node->link);
+ }
}
bool
@@ -168,10 +170,12 @@ hash_table_replace(struct hash_table *ht, void *data,
const void *key)
hn = calloc(1, sizeof(*hn));
- hn->data = data;
- hn->key = key;
+ if (hn != NULL) {
+ hn->data = data;
+ hn->key = key;
- insert_at_head(& ht->buckets[bucket], & hn->link);
+ insert_at_head(& ht->buckets[bucket], & hn->link);
+ }
return false;
}
--
1.8.1.2
_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev