diff options
author | Matthias Clasen <matthiasc@src.gnome.org> | 2002-02-10 21:06:15 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2002-02-10 21:06:15 +0000 |
commit | 73aa2bfe050ec9c1ae4cb2e913d46f550ce19668 (patch) | |
tree | 170366183831f6d7981efe75e87787910915c0c1 /gdk-pixbuf/io-wbmp.c | |
parent | 8846275862f6362bfd211c53cf21ebe826da01c3 (diff) | |
download | gtk+-73aa2bfe050ec9c1ae4cb2e913d46f550ce19668.tar.gz |
Enable some tests which should work now.
* test-loaders.c (main): Enable some tests which should work
now.
* io-wbmp.c (gdk_pixbuf__wbmp_image_load_increment): Detect
invalid image dimensions and insufficient memory.
* io-tga.c (try_preload): Detect invalid image dimensions.
(gdk_pixbuf__tga_stop_load): Don't try to unref NULL pointers.
* io-ico.c (DecodeHeader): Detect some invalid headers and
don't segfault.
Diffstat (limited to 'gdk-pixbuf/io-wbmp.c')
-rw-r--r-- | gdk-pixbuf/io-wbmp.c | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/gdk-pixbuf/io-wbmp.c b/gdk-pixbuf/io-wbmp.c index d483e360c1..d4db78386d 100644 --- a/gdk-pixbuf/io-wbmp.c +++ b/gdk-pixbuf/io-wbmp.c @@ -268,8 +268,19 @@ static gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data, else if(context->need_width) { bv = get_mbi(context, &buf, &size, &context->width); - if(bv) + if(bv) { context->need_width = FALSE; + + if (context->width <= 0) { + g_set_error (error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_CORRUPT_IMAGE, + _("Image has zero width")); + + return FALSE; + } + } + } else if(context->need_height) { @@ -277,8 +288,26 @@ static gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data, if(bv) { context->need_height = FALSE; + + if (context->height <= 0) { + g_set_error (error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_CORRUPT_IMAGE, + _("Image has zero height")); + + return FALSE; + } + context->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, context->width, context->height); - g_assert(context->pixbuf); + + if (!context->pixbuf) { + g_set_error (error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, + _("Not enough memory to load image")); + return FALSE; + } + if(context->prepared_func) context->prepared_func(context->pixbuf, NULL, context->user_data); @@ -324,10 +353,18 @@ static gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data, } while(bv); - if(size) - return save_rest(context, buf, size); - else - return context->needmore; + if(size) { + bv = save_rest(context, buf, size); + if (!bv) { + g_set_error (error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_CORRUPT_IMAGE, + _("Couldn't save the rest")); + + return FALSE; + } + } + return TRUE; } void |