From a5269a0d00bdbc7061b28a4853d5e02a8143fa08 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 27 May 2004 15:23:56 +0000 Subject: [PATCH] handle an empty colormap. Fixes bug #143009. 2004-05-27 Sven Neumann * plug-ins/common/png.c (respin_cmap): handle an empty colormap. Fixes bug #143009. --- ChangeLog | 5 +++++ plug-ins/common/png.c | 22 ++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index b92776b60a..610b192114 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-05-27 Sven Neumann + + * plug-ins/common/png.c (respin_cmap): handle an empty colormap. + Fixes bug #143009. + 2004-05-27 Sven Neumann * libgimpwidgets/gimppickbutton.c: applied patch from Philip diff --git a/plug-ins/common/png.c b/plug-ins/common/png.c index a79785d506..29156f1d2e 100644 --- a/plug-ins/common/png.c +++ b/plug-ins/common/png.c @@ -1471,15 +1471,25 @@ respin_cmap (png_structp pp, GimpDrawable * drawable) { static const guchar trans[] = { 0 }; - gint colors; - guchar *before; - gint transparent; - gint cols, rows; - GimpPixelRgn pixel_rgn; - guchar *pixels; + + gint colors; + guchar *before; + gint transparent; + gint cols, rows; + GimpPixelRgn pixel_rgn; + guchar *pixels; before = gimp_image_get_cmap (image_ID, &colors); + /* + * Make sure there is something in the colormap. + */ + if (colors == 0) + { + before = g_new0 (guchar, 3); + colors = 1; + } + cols = drawable->width; rows = drawable->height;