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.
This commit is contained in:
Neil Roberts 2011-05-16 16:34:48 +01:00
parent f23a387359
commit eb109e6cc0

View File

@ -87,7 +87,7 @@ _cogl_primitive_new_with_attributes_unref (CoglVerticesMode mode,
attributes, attributes,
n_attributes); n_attributes);
for (i = 0; attributes[i]; i++) for (i = 0; i < n_attributes; i++)
cogl_object_unref (attributes[i]); cogl_object_unref (attributes[i]);
return primitive; return primitive;
@ -109,8 +109,7 @@ cogl_primitive_new (CoglVerticesMode mode,
; ;
va_end (ap); va_end (ap);
attributes = g_alloca (sizeof (CoglAttribute *) * (n_attributes + 1)); attributes = g_alloca (sizeof (CoglAttribute *) * n_attributes);
attributes[n_attributes] = NULL;
va_start (ap, n_vertices); va_start (ap, n_vertices);
for (i = 0; (attribute = va_arg (ap, CoglAttribute *)); i++) 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, return cogl_primitive_new_with_attributes (mode, n_vertices,
attributes, attributes,
i + 1); i);
} }
CoglPrimitive * CoglPrimitive *