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.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c
index c707d347a..6864a7895 100644
--- a/gdk-pixbuf/io-jpeg.c
+++ b/gdk-pixbuf/io-jpeg.c
@@ -693,7 +693,14 @@ gdk_pixbuf__jpeg_image_save (FILE *f,
g_return_val_if_fail (pixels != NULL, FALSE);
/* allocate a small buffer to convert image data */
- buf = g_malloc (w * 3 * sizeof (guchar));
+ buf = g_try_malloc (w * 3 * sizeof (guchar));
+ if (!buf) {
+ g_set_error (error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+ _("Couldn't allocate memory for loading JPEG file"));
+ return FALSE;
+ }
/* set up error handling */
jerr.pub.error_exit = fatal_error_handler;