From df32ea99608102bdef84b7aaf75d86082a1474af Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 23 Feb 2010 11:50:25 -0500 Subject: [PATCH] Prevent a crash in the TGA loader Reported in bug 609744. --- gdk-pixbuf/io-tga.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gdk-pixbuf/io-tga.c b/gdk-pixbuf/io-tga.c index e42758c198..0391e1eec9 100644 --- a/gdk-pixbuf/io-tga.c +++ b/gdk-pixbuf/io-tga.c @@ -679,7 +679,13 @@ static gboolean try_colormap(TGAContext *ctx, GError **err) static guint n; g_return_val_if_fail(ctx != NULL, FALSE); - g_return_val_if_fail(ctx->cmap_size > 0, TRUE); + + if (ctx->cmap_size == 0) { + g_set_error_literal(err, GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_CORRUPT_IMAGE, + _("Image is corrupted or truncated")); + return FALSE; + } ctx->cmap = g_try_malloc(sizeof(TGAColormap)); if (!ctx->cmap) {