[cogl] matrix-stack: getting parent ptr before freeing
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] matrix-stack: getting parent ptr before freeing
- Date: Thu, 6 Dec 2012 11:41:30 +0000 (UTC)
commit e5d836b84acb35a009854a0cc0892320023789d1
Author: Robert Bragg <robert linux intel com>
Date: Tue Nov 27 22:02:56 2012 +0000
matrix-stack: getting parent ptr before freeing
When unrefing a CoglMatrixEntry we walk up the ancestry unrefing and
freeing entries until we find an entry that doesn't need to be freed.
The problem fixed by this patch was that we didn't dereference the
parent member of each entry until after the entry was freed and so there
was the potential for reading a junk parent pointer back.
cogl/cogl-matrix-stack.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/cogl/cogl-matrix-stack.c b/cogl/cogl-matrix-stack.c
index e5ad10d..4d5b9eb 100644
--- a/cogl/cogl-matrix-stack.c
+++ b/cogl/cogl-matrix-stack.c
@@ -328,8 +328,12 @@ _cogl_matrix_entry_ref (CoglMatrixEntry *entry)
void
_cogl_matrix_entry_unref (CoglMatrixEntry *entry)
{
- for (; entry && --entry->ref_count <= 0; entry = entry->parent)
+ CoglMatrixEntry *parent;
+
+ for (; entry && --entry->ref_count <= 0; entry = parent)
{
+ parent = entry->parent;
+
switch (entry->op)
{
case COGL_MATRIX_OP_LOAD_IDENTITY:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]