diff options
author | Robert Bragg <robert@linux.intel.com> | 2012-06-20 18:04:25 +0100 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2012-07-09 22:40:37 +0100 |
commit | 1d27fedef9c599aa9976b809f18e0da1913cec26 (patch) | |
tree | 85c2152e3e1b7e7f1ca8f169b6cb4530d992c7ef | |
parent | a1a8cc00bfa2cecaf1007aec5f3dd95dc07b1786 (diff) | |
download | cogl-1d27fedef9c599aa9976b809f18e0da1913cec26.tar.gz |
stack: don't deref freed mem in _cogl_memory_stack_free
This fixes _cogl_memory_stack_free to ensure we don't dereference freed
memory as we iterate the sub-stacks to free them.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
-rw-r--r-- | cogl/cogl-memory-stack.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/cogl/cogl-memory-stack.c b/cogl/cogl-memory-stack.c index 826a8922..5f4547e8 100644 --- a/cogl/cogl-memory-stack.c +++ b/cogl/cogl-memory-stack.c @@ -177,10 +177,9 @@ _cogl_memory_stack_free (CoglMemoryStack *stack) { CoglMemorySubStack *sub_stack; - for (sub_stack = stack->sub_stacks.tqh_first; - sub_stack; - sub_stack = sub_stack->list_node.tqe_next) + while ((sub_stack = COGL_TAILQ_FIRST (&stack->sub_stacks))) { + COGL_TAILQ_REMOVE (&stack->sub_stacks, sub_stack, list_node); _cogl_memory_sub_stack_free (sub_stack); } |