summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2015-10-12 15:57:36 +0200
committerBenjamin Otte <otte@redhat.com>2015-10-12 16:10:57 +0200
commita2406409fec3480895b48962cd9d7e403aecd1c0 (patch)
tree4c6e1f499a5a0c6cb8487fd54c060c6bdd8d15a5
parent1b868581c678ecb63ecf2b43bdba8b5e89c69a01 (diff)
downloadgdk-pixbuf-a2406409fec3480895b48962cd9d7e403aecd1c0.tar.gz
tga: Error on incomplete image
Previously, we would silently ignore the case where the image didn't have enough pixels. That is not a good idea, in particular when we haven't even read a header.
-rw-r--r--gdk-pixbuf/io-tga.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/gdk-pixbuf/io-tga.c b/gdk-pixbuf/io-tga.c
index 7500359f6..5015cacd6 100644
--- a/gdk-pixbuf/io-tga.c
+++ b/gdk-pixbuf/io-tga.c
@@ -683,24 +683,25 @@ static gboolean gdk_pixbuf__tga_load_increment(gpointer data,
static gboolean gdk_pixbuf__tga_stop_load(gpointer data, GError **err)
{
TGAContext *ctx = (TGAContext *) data;
- g_return_val_if_fail(ctx != NULL, FALSE);
+ gboolean retval = TRUE;
+
+ g_return_val_if_fail (ctx != NULL, FALSE);
- if (ctx->pbuf)
+ if (ctx->pbuf == NULL || tga_pixels_remaining (ctx))
{
- TGAColor transparent_black = { 0, 0, 0, 0 };
- gsize remaining;
+ g_set_error_literal (err,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+ _("TGA image was truncated or incomplete."));
- for (remaining = tga_pixels_remaining (ctx); remaining; remaining--)
- {
- tga_write_pixel (ctx, &transparent_black);
- }
+ retval = FALSE;
}
g_free (ctx->hdr);
if (ctx->cmap)
colormap_free (ctx->cmap);
if (ctx->pbuf)
- g_object_unref (ctx->pbuf);
+ g_object_unref (ctx->pbuf);
gdk_pixbuf_buffer_queue_unref (ctx->input);
g_free (ctx);
return TRUE;