[gimp] plug-ins: handle memory allocation failure in JXL import
- From: Daniel Novomeský <dnovomesky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: handle memory allocation failure in JXL import
- Date: Fri, 22 Oct 2021 11:23:42 +0000 (UTC)
commit 422d5fec8fa4f944a922523508f7ac8b465cd059
Author: Daniel Novomesky <dnovomesky gmail com>
Date: Thu Oct 21 12:25:21 2021 +0200
plug-ins: handle memory allocation failure in JXL import
plug-ins/common/file-jpegxl.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/plug-ins/common/file-jpegxl.c b/plug-ins/common/file-jpegxl.c
index 16300607c3..91711b5e86 100644
--- a/plug-ins/common/file-jpegxl.c
+++ b/plug-ins/common/file-jpegxl.c
@@ -497,7 +497,20 @@ load_image (GFile *file,
return NULL;
}
- picture_buffer = g_malloc (result_size);
+ picture_buffer = g_try_malloc (result_size);
+ if (!picture_buffer)
+ {
+ g_set_error (error, G_FILE_ERROR, 0, "Memory could not be allocated.");
+ if (profile)
+ {
+ g_object_unref (profile);
+ }
+ JxlThreadParallelRunnerDestroy (runner);
+ JxlDecoderDestroy (decoder);
+ g_free (memory);
+ return NULL;
+ }
+
if (JxlDecoderSetImageOutBuffer (decoder, &pixel_format, picture_buffer, result_size) != JXL_DEC_SUCCESS)
{
g_set_error (error, G_FILE_ERROR, 0,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]