From 7e516f6348505c28c48aed8d21e6194cd1d5cee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 9 Jul 2019 16:12:33 +0200 Subject: [PATCH 03/28] cogl/vertex-buffer: Don't try to use free'd data set_attribute_enable might try to warn using cogl_attribute_name after that has been free'd. Avoid this using an auto-pointer. https://gitlab.gnome.org/GNOME/mutter/merge_requests/682 --- cogl/cogl/deprecated/cogl-vertex-buffer.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cogl/cogl/deprecated/cogl-vertex-buffer.c b/cogl/cogl/deprecated/cogl-vertex-buffer.c index cf6e51ea2..59381dc56 100644 --- a/cogl/cogl/deprecated/cogl-vertex-buffer.c +++ b/cogl/cogl/deprecated/cogl-vertex-buffer.c @@ -590,66 +590,65 @@ cogl_vertex_buffer_delete (CoglHandle handle, /* The submit function works by diffing between submitted_attributes * and new_attributes to minimize the upload bandwidth + cost of * allocating new VBOs, so if there isn't already a list of new_attributes * we create one: */ if (!buffer->new_attributes) buffer->new_attributes = copy_submitted_attributes_list (buffer); for (tmp = buffer->new_attributes; tmp != NULL; tmp = tmp->next) { CoglVertexBufferAttrib *submitted_attribute = tmp->data; if (submitted_attribute->name == name) { buffer->new_attributes = g_list_delete_link (buffer->new_attributes, tmp); _cogl_vertex_buffer_attrib_free (submitted_attribute); return; } } g_warning ("Failed to find an attribute named %s to delete\n", attribute_name); } static void set_attribute_enable (CoglHandle handle, const char *attribute_name, CoglBool state) { CoglVertexBuffer *buffer; - char *cogl_attribute_name = canonize_attribute_name (attribute_name); + g_autofree char *cogl_attribute_name = + canonize_attribute_name (attribute_name); GQuark name_quark = g_quark_from_string (cogl_attribute_name); GList *tmp; - g_free (cogl_attribute_name); - if (!cogl_is_vertex_buffer (handle)) return; buffer = handle; buffer->dirty_attributes = TRUE; /* NB: If a buffer is currently being edited, then there can be two seperate * lists of attributes; those that are currently submitted and a new list yet * to be submitted, we need to modify both. */ for (tmp = buffer->new_attributes; tmp != NULL; tmp = tmp->next) { CoglVertexBufferAttrib *attribute = tmp->data; if (attribute->name == name_quark) { if (state) attribute->flags |= COGL_VERTEX_BUFFER_ATTRIB_FLAG_ENABLED; else attribute->flags &= ~COGL_VERTEX_BUFFER_ATTRIB_FLAG_ENABLED; break; } } for (tmp = buffer->submitted_vbos; tmp != NULL; tmp = tmp->next) { CoglVertexBufferVBO *cogl_vbo = tmp->data; GList *tmp2; for (tmp2 = cogl_vbo->attributes; tmp2 != NULL; tmp2 = tmp2->next) { -- 2.26.2