summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2011-05-16 16:34:48 +0100
committerNeil Roberts <neil@linux.intel.com>2011-05-16 18:34:22 +0100
commiteb109e6cc09e9024ad5303f02e34bc2de00ad8e7 (patch)
treed6be892a3b4803cf6551e0a3b4aca21e8e305e85
parentf23a387359fd6634169383ca4555813f2464780b (diff)
downloadcogl-eb109e6cc09e9024ad5303f02e34bc2de00ad8e7.tar.gz
cogl-primitive: Fix some broken changes for removal of NULL terminator
Commit 3c1e83c7 changed uses of arrays of CoglAttributes to take a length instead of being NULL terminated. In cogl_primitive_new it was still adding the NULL terminator to the array it passes to cogl_primitive_new_with_attributes but then it was also including this terminator in the count so it would just segfault when it tries to ref the NULL pointer. Also _cogl_primitive_new_with_attributes_unref was still trying to detect the NULL terminator so it would also crash.
-rw-r--r--cogl/cogl-primitive.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/cogl/cogl-primitive.c b/cogl/cogl-primitive.c
index b47c4189..dace7c69 100644
--- a/cogl/cogl-primitive.c
+++ b/cogl/cogl-primitive.c
@@ -87,7 +87,7 @@ _cogl_primitive_new_with_attributes_unref (CoglVerticesMode mode,
attributes,
n_attributes);
- for (i = 0; attributes[i]; i++)
+ for (i = 0; i < n_attributes; i++)
cogl_object_unref (attributes[i]);
return primitive;
@@ -109,8 +109,7 @@ cogl_primitive_new (CoglVerticesMode mode,
;
va_end (ap);
- attributes = g_alloca (sizeof (CoglAttribute *) * (n_attributes + 1));
- attributes[n_attributes] = NULL;
+ attributes = g_alloca (sizeof (CoglAttribute *) * n_attributes);
va_start (ap, n_vertices);
for (i = 0; (attribute = va_arg (ap, CoglAttribute *)); i++)
@@ -119,7 +118,7 @@ cogl_primitive_new (CoglVerticesMode mode,
return cogl_primitive_new_with_attributes (mode, n_vertices,
attributes,
- i + 1);
+ i);
}
CoglPrimitive *