gimp/SOURCES/gimp-2.8.22-fix-fclose-leak.patch

480 lines
16 KiB
Diff
Raw Normal View History

From 523d9b4e96da5de6f6324fa727df1ac2cc36371a Mon Sep 17 00:00:00 2001
From: Josef Ridky <jridky@redhat.com>
Date: Thu, 23 Aug 2018 10:05:34 +0200
Subject: [PATCH] OpenScanHub: Fix a leak with missing fclose in file-xmc.c
cherry picked from commit 2987f012f9289b7d608adbccc73166800b3dcf6a
The code to output "seems to have an incorrect toc size." is not
implemented, so no change about the part from the same commit.
---
plug-ins/common/file-cel.c | 9 +++++
plug-ins/common/file-gif-load.c | 12 ++++++
plug-ins/common/file-xbm.c | 6 +++
plug-ins/common/file-xmc.c | 53 +++++++++++++++++++-------
plug-ins/file-fli/fli-gimp.c | 11 +++++-
plug-ins/pygimp/plug-ins/whirlpinch.py | 2 +-
6 files changed, 77 insertions(+), 16 deletions(-)
diff --git a/plug-ins/common/file-cel.c b/plug-ins/common/file-cel.c
index 4803275aa5..12418c4949 100644
--- a/plug-ins/common/file-cel.c
+++ b/plug-ins/common/file-cel.c
@@ -365,6 +365,7 @@ load_image (const gchar *file,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("EOF or error while reading image header"));
+ fclose (fp);
return -1;
}
@@ -385,6 +386,7 @@ load_image (const gchar *file,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("EOF or error while reading image header"));
+ fclose (fp);
return -1;
}
@@ -393,6 +395,7 @@ load_image (const gchar *file,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("is not a CEL image file"));
+ fclose (fp);
return -1;
}
@@ -407,6 +410,7 @@ load_image (const gchar *file,
default:
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("illegal bpp value in image: %hhu"), bpp);
+ fclose (fp);
return -1;
}
@@ -423,6 +427,7 @@ load_image (const gchar *file,
_("illegal image dimensions: width: %d, horizontal offset: "
"%d, height: %d, vertical offset: %d"),
width, offx, height, offy);
+ fclose (fp);
return -1;
}
@@ -472,6 +477,7 @@ load_image (const gchar *file,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("EOF or error while reading image data"));
+ fclose (fp);
return -1;
}
@@ -507,6 +513,7 @@ load_image (const gchar *file,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("EOF or error while reading image data"));
+ fclose (fp);
return -1;
}
@@ -532,6 +539,7 @@ load_image (const gchar *file,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("EOF or error while reading image data"));
+ fclose (fp);
return -1;
}
@@ -549,6 +557,7 @@ load_image (const gchar *file,
default:
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Unsupported bit depth (%d)!"), bpp);
+ fclose (fp);
return -1;
}
diff --git a/plug-ins/common/file-gif-load.c b/plug-ins/common/file-gif-load.c
index 2aee9f37d9..9aa3f6ca0f 100644
--- a/plug-ins/common/file-gif-load.c
+++ b/plug-ins/common/file-gif-load.c
@@ -365,6 +365,7 @@ load_image (const gchar *filename,
if (! ReadOK (fd, buf, 6))
{
g_message ("Error reading magic number");
+ fclose (fd);
return -1;
}
@@ -372,6 +373,7 @@ load_image (const gchar *filename,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
"%s", _("This is not a GIF file"));
+ fclose (fd);
return -1;
}
@@ -381,12 +383,14 @@ load_image (const gchar *filename,
if ((strcmp (version, "87a") != 0) && (strcmp (version, "89a") != 0))
{
g_message ("Bad version number, not '87a' or '89a'");
+ fclose (fd);
return -1;
}
if (! ReadOK (fd, buf, 7))
{
g_message ("Failed to read screen descriptor");
+ fclose (fd);
return -1;
}
@@ -404,6 +408,7 @@ load_image (const gchar *filename,
&GifScreen.GrayScale))
{
g_message ("Error reading global colormap");
+ fclose (fd);
return -1;
}
}
@@ -421,12 +426,14 @@ load_image (const gchar *filename,
if (! ReadOK (fd, &c, 1))
{
g_message ("EOF / read error on image data");
+ fclose (fd);
return image_ID; /* will be -1 if failed on first image! */
}
if (c == ';')
{
/* GIF terminator */
+ fclose (fd);
return image_ID;
}
@@ -436,6 +443,7 @@ load_image (const gchar *filename,
if (! ReadOK (fd, &c, 1))
{
g_message ("EOF / read error on extension function code");
+ fclose (fd);
return image_ID; /* will be -1 if failed on first image! */
}
@@ -455,6 +463,7 @@ load_image (const gchar *filename,
if (! ReadOK (fd, buf, 9))
{
g_message ("Couldn't read left/top/width/height");
+ fclose (fd);
return image_ID; /* will be -1 if failed on first image! */
}
@@ -467,6 +476,7 @@ load_image (const gchar *filename,
if (! ReadColorMap (fd, bitPixel, localColorMap, &grayScale))
{
g_message ("Error reading local colormap");
+ fclose (fd);
return image_ID; /* will be -1 if failed on first image! */
}
@@ -514,6 +524,8 @@ load_image (const gchar *filename,
break;
}
+ fclose (fd);
+
return image_ID;
}
diff --git a/plug-ins/common/file-xbm.c b/plug-ins/common/file-xbm.c
index cdf30eaf90..5737001792 100644
--- a/plug-ins/common/file-xbm.c
+++ b/plug-ins/common/file-xbm.c
@@ -820,6 +820,7 @@ load_image (const gchar *filename,
{
g_message (_("'%s':\nCould not read header (ftell == %ld)"),
gimp_filename_to_utf8 (filename), ftell (fp));
+ fclose (fp);
return -1;
}
@@ -827,6 +828,7 @@ load_image (const gchar *filename,
{
g_message (_("'%s':\nNo image width specified"),
gimp_filename_to_utf8 (filename));
+ fclose (fp);
return -1;
}
@@ -834,6 +836,7 @@ load_image (const gchar *filename,
{
g_message (_("'%s':\nImage width is larger than GIMP can handle"),
gimp_filename_to_utf8 (filename));
+ fclose (fp);
return -1;
}
@@ -841,6 +844,7 @@ load_image (const gchar *filename,
{
g_message (_("'%s':\nNo image height specified"),
gimp_filename_to_utf8 (filename));
+ fclose (fp);
return -1;
}
@@ -848,6 +852,7 @@ load_image (const gchar *filename,
{
g_message (_("'%s':\nImage height is larger than GIMP can handle"),
gimp_filename_to_utf8 (filename));
+ fclose (fp);
return -1;
}
@@ -855,6 +860,7 @@ load_image (const gchar *filename,
{
g_message (_("'%s':\nNo image data type specified"),
gimp_filename_to_utf8 (filename));
+ fclose (fp);
return -1;
}
diff --git a/plug-ins/common/file-xmc.c b/plug-ins/common/file-xmc.c
index a75c8fbde3..6d054fc4cc 100644
--- a/plug-ins/common/file-xmc.c
+++ b/plug-ins/common/file-xmc.c
@@ -659,10 +659,11 @@ load_image (const gchar *filename, GError **error)
return -1;
}
- if (!XcursorFileLoad (fp, &commentsp, &imagesp))
+ if (! XcursorFileLoad (fp, &commentsp, &imagesp))
{
g_set_error (error, 0, 0, _("'%s' is not a valid X cursor."),
gimp_filename_to_utf8 (filename));
+ fclose (fp);
return -1;
}
@@ -679,6 +680,7 @@ load_image (const gchar *filename, GError **error)
g_set_error (error, 0, 0,
_("Frame %d of '%s' is too wide for an X cursor."),
i + 1, gimp_filename_to_utf8 (filename));
+ fclose (fp);
return -1;
}
if (imagesp->images[i]->height > MAX_LOAD_DIMENSION)
@@ -686,6 +688,7 @@ load_image (const gchar *filename, GError **error)
g_set_error (error, 0, 0,
_("Frame %d of '%s' is too high for an X cursor."),
i + 1, gimp_filename_to_utf8 (filename));
+ fclose (fp);
return -1;
}
}
@@ -704,7 +707,10 @@ load_image (const gchar *filename, GError **error)
gimp_image_set_filename (image_ID, filename);
if (! set_hotspot_to_parasite (image_ID))
- return -1;
+ {
+ fclose (fp);
+ return -1;
+ }
/* Temporary buffer */
tmppixel = g_new (guint32, img_width * img_height);
@@ -722,9 +728,12 @@ load_image (const gchar *filename, GError **error)
,i ,delay, imagesp->images[i]->width, imagesp->images[i]->height);
framename = make_framename (imagesp->images[i]->size, delay,
- DISPLAY_DIGIT(imagesp->nimage), error);
- if (!framename)
- return -1;
+ DISPLAY_DIGIT (imagesp->nimage), error);
+ if (! framename)
+ {
+ fclose (fp);
+ return -1;
+ }
layer_ID = gimp_layer_new (image_ID, framename,
imagesp->images[i]->width,
@@ -782,6 +791,7 @@ load_image (const gchar *filename, GError **error)
parasiteName[commentsp->comments[i]->comment_type -1]))
{
DM_XMC ("Failed to write %ith comment.\n", i);
+ fclose (fp);
return -1;
}
}
@@ -889,6 +899,7 @@ load_thumbnail (const gchar *filename, gint32 thumb_size,
g_set_error (error, 0, 0,
_("there is no image chunk in \"%s\"."),
gimp_filename_to_utf8 (filename));
+ fclose (fp);
return -1;
}
@@ -931,6 +942,7 @@ load_thumbnail (const gchar *filename, gint32 thumb_size,
g_set_error (error, 0, 0,
_("'%s' is too wide for an X cursor."),
gimp_filename_to_utf8 (filename));
+ fclose (fp);
return -1;
}
if (*thumb_height > MAX_LOAD_DIMENSION)
@@ -938,6 +950,7 @@ load_thumbnail (const gchar *filename, gint32 thumb_size,
g_set_error (error, 0, 0,
_("'%s' is too high for an X cursor."),
gimp_filename_to_utf8 (filename));
+ fclose (fp);
return -1;
}
@@ -1462,7 +1475,8 @@ save_image (const gchar *filename,
imagesp = XcursorImagesCreate(nlayers);
if (!imagesp)
{
- DM_XMC("Failed to XcursorImagesCreate!\n");
+ DM_XMC ("Failed to XcursorImagesCreate!\n");
+ fclose (fp);
return FALSE;
}
imagesp->nimage = nlayers;
@@ -1499,14 +1513,18 @@ save_image (const gchar *filename,
{
g_set_error (error, 0, 0,
_("Frame '%s' is too wide. Please reduce to no more than %dpx."),
- gimp_any_to_utf8 (framename, -1, NULL), MAX_SAVE_DIMENSION);
+ gimp_any_to_utf8 (framename, -1, NULL),
+ MAX_SAVE_DIMENSION);
+ fclose (fp);
return FALSE;
}
if (drawable->height > MAX_SAVE_DIMENSION)
{
g_set_error (error, 0, 0,
_("Frame '%s' is too high. Please reduce to no more than %dpx."),
- gimp_any_to_utf8 (framename, -1, NULL), MAX_SAVE_DIMENSION);
+ gimp_any_to_utf8 (framename, -1, NULL),
+ MAX_SAVE_DIMENSION);
+ fclose (fp);
return FALSE;
}
if (drawable->height == 0 ||drawable->width == 0)
@@ -1514,6 +1532,7 @@ save_image (const gchar *filename,
g_set_error (error, 0, 0,
_("Width and/or height of frame '%s' is zero!"),
gimp_any_to_utf8 (framename, -1, NULL));
+ fclose (fp);
return FALSE;
}
@@ -1535,6 +1554,7 @@ save_image (const gchar *filename,
if (!imagesp->images[i])
{
DM_XMC ("Failed to XcursorImageCreate.\n");
+ fclose (fp);
return FALSE;
}
imagesp->images[i]->pixels[0] = 0x0;
@@ -1557,6 +1577,7 @@ save_image (const gchar *filename,
"Try to change the hot spot position, "
"layer geometry or save without auto-crop."),
gimp_any_to_utf8 (framename, -1, NULL));
+ fclose (fp);
return FALSE;
}
}
@@ -1589,6 +1610,7 @@ save_image (const gchar *filename,
if (!imagesp->images[i])
{
DM_XMC ("Failed to XcursorImageCreate.\n");
+ fclose (fp);
return FALSE;
}
/*
@@ -1636,8 +1658,11 @@ save_image (const gchar *filename,
imagesp->images[i]->delay,
DISPLAY_DIGIT(imagesp->nimage),
error);
- if (!framename)
- return FALSE;
+ if (! framename)
+ {
+ fclose (fp);
+ return FALSE;
+ }
gimp_item_set_name (orig_layers[nlayers - 1 - i], framename);
g_free (framename);
@@ -1691,8 +1716,9 @@ save_image (const gchar *filename,
{
if (! XcursorFileSave (fp, commentsp, imagesp))
{
- DM_XMC("Failed to XcursorFileSave.\t%p\t%p\t%p\n",
- fp, commentsp, imagesp);
+ DM_XMC ("Failed to XcursorFileSave.\t%p\t%p\t%p\n",
+ fp, commentsp, imagesp);
+ fclose (fp);
return FALSE;
}
@@ -1701,7 +1727,8 @@ save_image (const gchar *filename,
{
if (! XcursorFileSaveImages (fp, imagesp))
{
- DM_XMC("Failed to XcursorFileSaveImages.\t%p\t%p\n", fp, imagesp);
+ DM_XMC ("Failed to XcursorFileSaveImages.\t%p\t%p\n", fp, imagesp);
+ fclose (fp);
return FALSE;
}
}
diff --git a/plug-ins/file-fli/fli-gimp.c b/plug-ins/file-fli/fli-gimp.c
index e3843eb5db..be772d3c3f 100644
--- a/plug-ins/file-fli/fli-gimp.c
+++ b/plug-ins/file-fli/fli-gimp.c
@@ -505,9 +505,14 @@ load_image (const gchar *filename,
fli_read_header (file, &fli_header);
if (fli_header.magic == NO_HEADER)
- return -1;
+ {
+ fclose (file);
+ return -1;
+ }
else
- fseek (file, 128, SEEK_SET);
+ {
+ fseek (file, 128, SEEK_SET);
+ }
/*
* Fix parameters
@@ -528,11 +533,13 @@ load_image (const gchar *filename,
if (to_frame < 1)
{
/* nothing to do ... */
+ fclose (file);
return -1;
}
if (from_frame >= fli_header.frames)
{
/* nothing to do ... */
+ fclose (file);
return -1;
}
if (to_frame>fli_header.frames)
diff --git a/plug-ins/pygimp/plug-ins/whirlpinch.py b/plug-ins/pygimp/plug-ins/whirlpinch.py
index 7897f13294..e1fbc376de 100755
--- a/plug-ins/pygimp/plug-ins/whirlpinch.py
+++ b/plug-ins/pygimp/plug-ins/whirlpinch.py
@@ -125,7 +125,7 @@ def whirl_pinch(image, drawable, whirl, pinch, radius):
if cx >= 0: ix = int(cx)
else: ix = -(int(-cx) + 1)
if cy >= 0: iy = int(cy)
- else: iy = -(int(-cx) + 1)
+ else: iy = -(int(-cy) + 1)
pixel[0] = pft.get_pixel(ix, iy)
pixel[1] = pft.get_pixel(ix+1, iy)
pixel[2] = pft.get_pixel(ix, iy+1)
--
2.43.0