libgimp: Always pass size to g_bytes_unref_to_data

Unlike `g_bytes_get_data()`, the out argument for the size is not
optional, so if we try to pass `NULL` there, we actually get a segfault.
This commit is contained in:
Niels De Graef 2023-05-24 23:16:36 +02:00
parent e1e30c6f72
commit 00415bed6a
2 changed files with 6 additions and 3 deletions

View File

@ -406,6 +406,7 @@ gimp_brush_select_button_get_brush_bitmap (GimpBrushSelectButton *self)
GimpBrush *brush;
gint mask_bpp;
GBytes *mask_data;
gsize mask_size;
gint color_bpp;
GBytes *color_data;
_PreviewBitmap result;
@ -422,7 +423,7 @@ gimp_brush_select_button_get_brush_bitmap (GimpBrushSelectButton *self)
&color_bpp,
&color_data);
result.mask_data = g_bytes_unref_to_data (mask_data, NULL);
result.mask_data = g_bytes_unref_to_data (mask_data, &mask_size);
/* Discard any color data, bitmap is B&W i.e. i.e. depth one i.e. a mask */
g_bytes_unref (color_data);

View File

@ -133,6 +133,7 @@ gimp_drawable_get_thumbnail (GimpDrawable *drawable,
{
gint thumb_width, thumb_height, thumb_bpp;
GBytes *data;
gsize data_size;
GdkPixbuf *pixbuf = NULL;
g_return_val_if_fail (width > 0 && width <= 1024, NULL);
@ -146,7 +147,7 @@ gimp_drawable_get_thumbnail (GimpDrawable *drawable,
&thumb_bpp);
if (data)
pixbuf = _gimp_pixbuf_from_data (g_bytes_unref_to_data (data, NULL),
pixbuf = _gimp_pixbuf_from_data (g_bytes_unref_to_data (data, &data_size),
thumb_width, thumb_height, thumb_bpp,
alpha);
@ -238,6 +239,7 @@ gimp_drawable_get_sub_thumbnail (GimpDrawable *drawable,
gint thumb_height = dest_height;
gint thumb_bpp;
GBytes *data;
gsize data_size;
GdkPixbuf *pixbuf = NULL;
g_return_val_if_fail (src_x >= 0, NULL);
@ -256,7 +258,7 @@ gimp_drawable_get_sub_thumbnail (GimpDrawable *drawable,
&thumb_bpp);
if (data)
pixbuf = _gimp_pixbuf_from_data (g_bytes_unref_to_data (data, NULL),
pixbuf = _gimp_pixbuf_from_data (g_bytes_unref_to_data (data, &data_size),
thumb_width, thumb_height, thumb_bpp,
alpha);
g_bytes_unref (data);