mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-10-06 01:12:40 +02:00
core, plug-ins: Fix bugs noted by Coverity scan
Fixes the following warnings from Coverity: * file-paa.c: Casts "width" to guint32 to prevent overflow. Also, fix checks so that RGBA_8888 textures will be read. * file-png.c: Free variables if APNG is not fully loaded * file-seattle-filmworks.c: Verify fseek () doesn't exceed length of file * file-tim.c: Casts "width" to guint32 to prevent overflow * guillotine.c: Free "file" if image creation fails * gimpitem.c: Initialize offset_x/y to 0 to remove warning
This commit is contained in:
@@ -43,8 +43,8 @@ typedef enum
|
||||
{
|
||||
RGBA_4444 = 0x4444,
|
||||
RGBA_5551 = 0x1555,
|
||||
RGBA_8888 = 0x8888,
|
||||
GRAY_ALPHA = 0x8080,
|
||||
RGBA_8888 = 0x8888,
|
||||
DXT1 = 0xFF01,
|
||||
DXT2 = 0xFF02,
|
||||
DXT3 = 0xFF03,
|
||||
@@ -327,11 +327,11 @@ load_image (GFile *file,
|
||||
buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer));
|
||||
|
||||
/* Non-DDS textures are compressed with LZSS */
|
||||
if (paa_type <= GRAY_ALPHA)
|
||||
if (paa_type <= RGBA_8888)
|
||||
{
|
||||
guchar *uncompressed_data;
|
||||
gint estimated_size;
|
||||
guint dims = width * height;
|
||||
guint dims = (guint32) width * height;
|
||||
guchar pixels[dims * 4];
|
||||
|
||||
if (paa_type != RGBA_8888)
|
||||
|
@@ -1392,6 +1392,9 @@ load_apng_image (GFile *file,
|
||||
if (! png_id)
|
||||
{
|
||||
fclose (fp);
|
||||
if (ihdr_chunk.data)
|
||||
g_free (ihdr_chunk.data);
|
||||
|
||||
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
|
||||
_("Could not read APNG frames. "
|
||||
"They will be discarded."));
|
||||
@@ -1426,6 +1429,9 @@ load_apng_image (GFile *file,
|
||||
else
|
||||
{
|
||||
fclose (fp);
|
||||
if (ihdr_chunk.data)
|
||||
g_free (ihdr_chunk.data);
|
||||
|
||||
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
|
||||
_("Could not read APNG frames. "
|
||||
"They will be discarded."));
|
||||
@@ -1600,6 +1606,8 @@ load_apng_image (GFile *file,
|
||||
}
|
||||
g_list_free (other_chunks);
|
||||
}
|
||||
if (prior_pixels)
|
||||
g_free (prior_pixels);
|
||||
}
|
||||
|
||||
fclose (fp);
|
||||
|
@@ -506,9 +506,8 @@ load_sfw93a (FILE *fp,
|
||||
FILE *temp_fp;
|
||||
guchar data[file_size - 30];
|
||||
|
||||
fseek (fp, 30, SEEK_SET);
|
||||
|
||||
if (fread (&data, file_size - 30, 1, fp) != 1)
|
||||
if (fseek (fp, 30, SEEK_SET) < 0 ||
|
||||
fread (&data, file_size - 30, 1, fp) != 1)
|
||||
{
|
||||
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
|
||||
_("Invalid file."));
|
||||
|
@@ -768,7 +768,7 @@ export_image (GFile *file,
|
||||
fwrite (&height, 2, 1, fp);
|
||||
|
||||
/* Writing actual image data */
|
||||
indexes = g_malloc (width * height);
|
||||
indexes = g_malloc ((guint32) width * height);
|
||||
gegl_buffer_get (buffer, GEGL_RECTANGLE (0, 0, width, height),
|
||||
1.0, NULL, indexes,
|
||||
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
|
||||
|
@@ -284,6 +284,7 @@ guillotine (GimpImage *image,
|
||||
if (! new_image)
|
||||
{
|
||||
g_warning ("Couldn't create new image.");
|
||||
g_object_unref (file);
|
||||
g_free (hformat);
|
||||
g_free (format);
|
||||
return images;
|
||||
|
Reference in New Issue
Block a user