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