util: make calling remove_from_list multiple times in a row safe
authorMarek Olšák <maraeo@gmail.com>
Thu, 23 Sep 2010 18:39:27 +0000 (20:39 +0200)
committerMarek Olšák <maraeo@gmail.com>
Fri, 24 Sep 2010 00:29:04 +0000 (02:29 +0200)
This commit fixes an infinite loop in foreach_s if remove_from_list is used
more than once on the same item with other list operations in between.

NOTE: This is a candidate for the 7.9 branch because the commit
"r300g: fixup long-lived BO maps being incorrectly unmapped when flushing"
depends on it.

src/gallium/auxiliary/util/u_simple_list.h

index f5f43b0faa200b4b8681a37d2f5c9a4223d5110f..fe59771371b516d714d0e1a613665469058d9ad6 100644 (file)
@@ -46,6 +46,8 @@
 do {                                           \
    (elem)->next->prev = (elem)->prev;          \
    (elem)->prev->next = (elem)->next;          \
+   (elem)->next = elem;                         \
+   (elem)->prev = elem;                         \
 } while (0)
 
 /**