From ab9856c52acf6846d94478e5e8cdcf4d400512c5 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Tue, 24 Jan 2006 23:05:56 +0000 Subject: [project @ 2006-01-24 23:05:56 by rjw] Handle memory failure better. svn path=/import/netsurf/; revision=2030 --- image/jpeg.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'image/jpeg.c') diff --git a/image/jpeg.c b/image/jpeg.c index 80f4019be..86f205964 100644 --- a/image/jpeg.c +++ b/image/jpeg.c @@ -67,7 +67,7 @@ bool nsjpeg_convert(struct content *c, int w, int h) unsigned int height; unsigned int width; struct bitmap *bitmap = NULL; - char *pixels; + char *pixels = NULL; size_t rowstride; union content_msg_data msg_data; @@ -95,8 +95,12 @@ bool nsjpeg_convert(struct content *c, int w, int h) height = cinfo.output_height; bitmap = bitmap_create(width, height, false); - if (!bitmap) { + if (bitmap) + pixels = bitmap_get_buffer(bitmap); + if ((!bitmap) || (!pixels)) { jpeg_destroy_decompress(&cinfo); + if (bitmap) + bitmap_destroy(bitmap); msg_data.error = messages_get("NoMemory"); content_broadcast(c, CONTENT_MSG_ERROR, msg_data); @@ -105,7 +109,6 @@ bool nsjpeg_convert(struct content *c, int w, int h) } bitmap_set_opaque(bitmap, true); - pixels = bitmap_get_buffer(bitmap); rowstride = bitmap_get_rowstride(bitmap); do { JSAMPROW scanlines[1]; -- cgit v1.2.3