mesa: add missing null check in _mesa_NewHashTable()
authorJuha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Wed, 26 Feb 2014 12:03:19 +0000 (14:03 +0200)
committerTapani Pälli <tapani.palli@intel.com>
Fri, 30 May 2014 04:20:53 +0000 (07:20 +0300)
Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/hash.c

index 23018e9da319224fec22d281c33c45ece8d62c7d..674c29d650ba22840c45fa38e8eb8a37d3035e60 100644 (file)
@@ -115,10 +115,20 @@ _mesa_NewHashTable(void)
 
    if (table) {
       table->ht = _mesa_hash_table_create(NULL, uint_key_compare);
+      if (table->ht == NULL) {
+         free(table);
+         _mesa_error_no_memory(__func__);
+         return NULL;
+      }
+
       _mesa_hash_table_set_deleted_key(table->ht, uint_key(DELETED_KEY_VALUE));
       mtx_init(&table->Mutex, mtx_plain);
       mtx_init(&table->WalkMutex, mtx_plain);
    }
+   else {
+      _mesa_error_no_memory(__func__);
+   }
+
    return table;
 }