mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 05:01:09 +00:00
memory texture: Fix a memory leak
The callers assumed that gdk_memory_sanitize is transfer full in both directions, but it wasn't. Make it so.
This commit is contained in:
parent
bbb7b365d5
commit
d718fda057
@ -111,7 +111,7 @@ gdk_memory_sanitize (GBytes *bytes,
|
||||
stride % align == 0)
|
||||
{
|
||||
*out_stride = stride;
|
||||
return g_bytes_ref (bytes);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
bpp = gdk_memory_format_bytes_per_pixel (format);
|
||||
@ -122,6 +122,8 @@ gdk_memory_sanitize (GBytes *bytes,
|
||||
for (y = 0; y < height; y++)
|
||||
memcpy (copy + y * copy_stride, data + y * stride, bpp * width);
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
*out_stride = copy_stride;
|
||||
return g_bytes_new_take (copy, copy_stride * height);
|
||||
}
|
||||
@ -197,7 +199,7 @@ gdk_memory_texture_new (int width,
|
||||
/* needs to be this complex to support subtexture of the bottom right part */
|
||||
g_return_val_if_fail (g_bytes_get_size (bytes) >= gdk_memory_format_min_buffer_size (format, stride, width, height), NULL);
|
||||
|
||||
bytes = gdk_memory_sanitize (bytes, width, height, format, stride, &stride);
|
||||
bytes = gdk_memory_sanitize (g_bytes_ref (bytes), width, height, format, stride, &stride);
|
||||
|
||||
self = g_object_new (GDK_TYPE_MEMORY_TEXTURE,
|
||||
"width", width,
|
||||
|
Loading…
Reference in New Issue
Block a user