[gnome-screenshot] utils: create same size pixbuf when using XShape



commit efd710e77dc726579eade140823d9774baad9c19
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Jul 24 16:45:17 2019 +0200

    utils: create same size pixbuf when using XShape
    
    gdk_pixbuf_get_from_window() takes into account the window scale
    factor, so we can't assume that by using screenshot_coords.width
    and screenshot_coords.height we'll create a pixbuf of the same
    size.
    Instead, just read the size of the original pixbuf.
    
    This fixes a memory corruption crash in the fallback X11 code path
    under HiDpi displays.

 src/screenshot-utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/src/screenshot-utils.c b/src/screenshot-utils.c
index b27a8c8..fc8c3eb 100644
--- a/src/screenshot-utils.c
+++ b/src/screenshot-utils.c
@@ -448,7 +448,8 @@ screenshot_fallback_get_pixbuf (GdkRectangle *rectangle)
         {
           gboolean has_alpha = gdk_pixbuf_get_has_alpha (screenshot);
           GdkPixbuf *tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
-                                           screenshot_coords.width, screenshot_coords.height);
+                                           gdk_pixbuf_get_width (screenshot),
+                                           gdk_pixbuf_get_height (screenshot));
           gdk_pixbuf_fill (tmp, 0);
 
           for (i = 0; i < rectangle_count; i++)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]