summaryrefslogtreecommitdiff
path: root/gdk-pixbuf/io-jpeg.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdk-pixbuf/io-jpeg.c')
-rw-r--r--gdk-pixbuf/io-jpeg.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c
index 6864a7895..f04c954f9 100644
--- a/gdk-pixbuf/io-jpeg.c
+++ b/gdk-pixbuf/io-jpeg.c
@@ -337,7 +337,16 @@ gdk_pixbuf__jpeg_image_begin_load (ModulePreparedNotifyFunc prepared_func,
/* create libjpeg structures */
jpeg_create_decompress (&context->cinfo);
- context->cinfo.src = (struct jpeg_source_mgr *) g_new0 (my_source_mgr, 1);
+ context->cinfo.src = (struct jpeg_source_mgr *) g_try_malloc (sizeof (my_source_mgr));
+ if (!context->cinfo.src) {
+ g_set_error (error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+ _("Couldn't allocate memory for loading JPEG file"));
+ return NULL;
+ }
+ memset (context->cinfo.src, 0, sizeof (my_source_mgr));
+
src = (my_src_ptr) context->cinfo.src;
context->cinfo.err = jpeg_std_error (&context->jerr.pub);