This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository legacy-imlib2.

View the commit online.

commit 5d16eb8bb858406c3041a69824dce479d1009628
Author: Kim Woelders <k...@woelders.dk>
AuthorDate: Fri Jan 13 15:48:26 2023 +0100

    api: Tweak/correct error handling in drawable grabbing functions
    
    imlib_create_scaled_image_from_drawable() now returns NULL if the
    drawable could not be grabbed, just as imlib_create_image_from_drawable()
    has always done.
---
 src/lib/api_x11.c | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/src/lib/api_x11.c b/src/lib/api_x11.c
index 2e1e510..efc2ff7 100644
--- a/src/lib/api_x11.c
+++ b/src/lib/api_x11.c
@@ -304,20 +304,19 @@ imlib_create_image_from_drawable(Pixmap mask, int x, int y, int width,
    if (!im)
       return NULL;
    im->data = "" * height * sizeof(uint32_t));
-   if (im->data &&
-       __imlib_GrabDrawableToRGBA(im->data, 0, 0, width, height, ctx->display,
-                                  ctx->drawable, mask, ctx->visual,
-                                  ctx->colormap, ctx->depth, x, y, width,
-                                  height, &domask, need_to_grab_x))
-     {
-        im->has_alpha = domask;
-     }
-   else
+
+   if (!im->data ||
+       !__imlib_GrabDrawableToRGBA(im->data, 0, 0, width, height, ctx->display,
+                                   ctx->drawable, mask, ctx->visual,
+                                   ctx->colormap, ctx->depth, x, y, width,
+                                   height, &domask, need_to_grab_x))
      {
         __imlib_FreeImage(im);
-        im = NULL;
+        return NULL;
      }
 
+   im->has_alpha = domask;
+
    return im;
 }
 
@@ -359,8 +358,6 @@ imlib_create_scaled_image_from_drawable(Pixmap mask, int src_x, int src_y,
    if (!IMAGE_DIMENSIONS_OK(dst_width, dst_height))
       return NULL;
 
-   domask = mask != 0 || get_mask_from_shape;
-
    im = __imlib_CreateImage(dst_width, dst_height, NULL);
    if (!im)
       return NULL;
@@ -371,11 +368,18 @@ imlib_create_scaled_image_from_drawable(Pixmap mask, int src_x, int src_y,
         return NULL;
      }
 
-   __imlib_GrabDrawableScaledToRGBA(im->data, 0, 0, dst_width, dst_height,
-                                    ctx->display, ctx->drawable, mask,
-                                    ctx->visual, ctx->colormap, ctx->depth,
-                                    src_x, src_y, src_width, src_height,
-                                    &domask, need_to_grab_x);
+   domask = mask != 0 || get_mask_from_shape;
+
+   if (!im->data ||
+       !__imlib_GrabDrawableScaledToRGBA(im->data, 0, 0, dst_width, dst_height,
+                                         ctx->display, ctx->drawable, mask,
+                                         ctx->visual, ctx->colormap, ctx->depth,
+                                         src_x, src_y, src_width, src_height,
+                                         &domask, need_to_grab_x))
+     {
+        __imlib_FreeImage(im);
+        return NULL;
+     }
 
    im->has_alpha = domask;
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to