mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
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:
parent
e1e30c6f72
commit
00415bed6a
2 changed files with 6 additions and 3 deletions
|
@ -406,6 +406,7 @@ gimp_brush_select_button_get_brush_bitmap (GimpBrushSelectButton *self)
|
||||||
GimpBrush *brush;
|
GimpBrush *brush;
|
||||||
gint mask_bpp;
|
gint mask_bpp;
|
||||||
GBytes *mask_data;
|
GBytes *mask_data;
|
||||||
|
gsize mask_size;
|
||||||
gint color_bpp;
|
gint color_bpp;
|
||||||
GBytes *color_data;
|
GBytes *color_data;
|
||||||
_PreviewBitmap result;
|
_PreviewBitmap result;
|
||||||
|
@ -422,7 +423,7 @@ gimp_brush_select_button_get_brush_bitmap (GimpBrushSelectButton *self)
|
||||||
&color_bpp,
|
&color_bpp,
|
||||||
&color_data);
|
&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 */
|
/* Discard any color data, bitmap is B&W i.e. i.e. depth one i.e. a mask */
|
||||||
g_bytes_unref (color_data);
|
g_bytes_unref (color_data);
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,7 @@ gimp_drawable_get_thumbnail (GimpDrawable *drawable,
|
||||||
{
|
{
|
||||||
gint thumb_width, thumb_height, thumb_bpp;
|
gint thumb_width, thumb_height, thumb_bpp;
|
||||||
GBytes *data;
|
GBytes *data;
|
||||||
|
gsize data_size;
|
||||||
GdkPixbuf *pixbuf = NULL;
|
GdkPixbuf *pixbuf = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (width > 0 && width <= 1024, NULL);
|
g_return_val_if_fail (width > 0 && width <= 1024, NULL);
|
||||||
|
@ -146,7 +147,7 @@ gimp_drawable_get_thumbnail (GimpDrawable *drawable,
|
||||||
&thumb_bpp);
|
&thumb_bpp);
|
||||||
|
|
||||||
if (data)
|
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,
|
thumb_width, thumb_height, thumb_bpp,
|
||||||
alpha);
|
alpha);
|
||||||
|
|
||||||
|
@ -238,6 +239,7 @@ gimp_drawable_get_sub_thumbnail (GimpDrawable *drawable,
|
||||||
gint thumb_height = dest_height;
|
gint thumb_height = dest_height;
|
||||||
gint thumb_bpp;
|
gint thumb_bpp;
|
||||||
GBytes *data;
|
GBytes *data;
|
||||||
|
gsize data_size;
|
||||||
GdkPixbuf *pixbuf = NULL;
|
GdkPixbuf *pixbuf = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (src_x >= 0, NULL);
|
g_return_val_if_fail (src_x >= 0, NULL);
|
||||||
|
@ -256,7 +258,7 @@ gimp_drawable_get_sub_thumbnail (GimpDrawable *drawable,
|
||||||
&thumb_bpp);
|
&thumb_bpp);
|
||||||
|
|
||||||
if (data)
|
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,
|
thumb_width, thumb_height, thumb_bpp,
|
||||||
alpha);
|
alpha);
|
||||||
g_bytes_unref (data);
|
g_bytes_unref (data);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue