gallium/u_slab: fix possible crash in util_slab_destroy
authorMarek Olšák <maraeo@gmail.com>
Tue, 21 Feb 2012 17:40:11 +0000 (18:40 +0100)
committerMarek Olšák <maraeo@gmail.com>
Thu, 23 Feb 2012 19:29:55 +0000 (20:29 +0100)
It may happen if util_slab_create has not been called.

Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
src/gallium/auxiliary/util/u_slab.c

index 21bf2d7..f9f5ef6 100644 (file)
@@ -160,9 +160,11 @@ void util_slab_destroy(struct util_slab_mempool *pool)
 {
    struct util_slab_page *page, *temp;
 
-   foreach_s(page, temp, &pool->list) {
-      remove_from_list(page);
-      FREE(page);
+   if (pool->list.next) {
+      foreach_s(page, temp, &pool->list) {
+         remove_from_list(page);
+         FREE(page);
+      }
    }
 
    pipe_mutex_destroy(pool->mutex);