mesa: Test for failed malloc in _mesa_HashInsert.
authorBrian Paul <brianp@vmware.com>
Tue, 16 Feb 2010 15:21:28 +0000 (08:21 -0700)
committerBrian Paul <brianp@vmware.com>
Tue, 16 Feb 2010 15:21:28 +0000 (08:21 -0700)
Signed-off-by: Brian Paul <brianp@vmware.com>
(cherry picked from commit 7c7247ddbf6e3f7f93e44c1cb52490044f1a2215)

src/mesa/main/hash.c

index 08c64568c83d369611510f8fb6cef0b94db2ea8c..7c3c7a6bdbb8533b97eaf97c2ac53c6430ca6339 100644 (file)
@@ -191,10 +191,12 @@ _mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data)
 
    /* alloc and insert new table entry */
    entry = MALLOC_STRUCT(HashEntry);
-   entry->Key = key;
-   entry->Data = data;
-   entry->Next = table->Table[pos];
-   table->Table[pos] = entry;
+   if (entry) {
+      entry->Key = key;
+      entry->Data = data;
+      entry->Next = table->Table[pos];
+      table->Table[pos] = entry;
+   }
 
    _glthread_UNLOCK_MUTEX(table->Mutex);
 }