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 675b69414a9624f3d848611f89dad12c6680ea1b
Author: NRK <[email protected]>
AuthorDate: Sun May 8 00:10:59 2022 +0600
check for some alloc failures
---
src/lib/api.c | 22 ++++++++++++++++++++--
src/lib/colormod.c | 2 ++
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/lib/api.c b/src/lib/api.c
index ceb7327..51f0a28 100644
--- a/src/lib/api.c
+++ b/src/lib/api.c
@@ -227,7 +227,8 @@ imlib_context_new(void)
{
ImlibContext *context = malloc(sizeof(ImlibContext));
- *context = ctx_default;
+ if (context)
+ *context = ctx_default;
return context;
}
@@ -1328,8 +1329,11 @@ imlib_create_image_from_drawable(Pixmap mask, int x, int y, int width,
mask = None;
}
im = __imlib_CreateImage(width, height, NULL);
+ if (!im)
+ return NULL;
im->data = "" * height * sizeof(uint32_t));
- if (__imlib_GrabDrawableToRGBA(im->data, 0, 0, width, height, ctx->display,
+ 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))
@@ -1354,7 +1358,14 @@ imlib_create_image_from_ximage(XImage * image, XImage * mask, int x, int y,
if (!IMAGE_DIMENSIONS_OK(width, height))
return NULL;
im = __imlib_CreateImage(width, height, NULL);
+ if (!im)
+ return NULL;
im->data = "" * height * sizeof(uint32_t));
+ if (!im->data)
+ {
+ __imlib_FreeImage(im);
+ return NULL;
+ }
__imlib_GrabXImageToRGBA(im->data, 0, 0, width, height,
ctx->display, image, mask, ctx->visual,
ctx->depth, x, y, width, height, need_to_grab_x);
@@ -1381,7 +1392,14 @@ imlib_create_scaled_image_from_drawable(Pixmap mask, int source_x,
domask = mask != 0 || get_mask_from_shape;
im = __imlib_CreateImage(destination_width, destination_height, NULL);
+ if (!im)
+ return NULL;
im->data = "" * destination_height * sizeof(uint32_t));
+ if (!im->data)
+ {
+ __imlib_FreeImage(im);
+ return NULL;
+ }
__imlib_GrabDrawableScaledToRGBA(im->data, 0, 0,
destination_width, destination_height,
diff --git a/src/lib/colormod.c b/src/lib/colormod.c
index 81c8f48..a133734 100644
--- a/src/lib/colormod.c
+++ b/src/lib/colormod.c
@@ -16,6 +16,8 @@ __imlib_CreateCmod(void)
int i;
cm = malloc(sizeof(ImlibColorModifier));
+ if (!cm)
+ return NULL;
cm->modification_count = mod_count;
for (i = 0; i < 256; i++)
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.