[maemo-commits] [maemo-commits] r17356 - in projects/haf/trunk/clutter: clutter/cogl/common clutter/x11 debian
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Feb 4 17:39:27 EET 2009
- Previous message: [maemo-commits] r17355 - in projects/haf/trunk/hildon-thumbnail: . daemon tests
- Next message: [maemo-commits] r17357 - projects/haf/trunk/dbus/debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: kihamala
Date: 2009-02-04 17:39:11 +0200 (Wed, 04 Feb 2009)
New Revision: 17356
Modified:
projects/haf/trunk/clutter/clutter/cogl/common/cogl-bitmap.c
projects/haf/trunk/clutter/clutter/cogl/common/cogl-pvr-texture.c
projects/haf/trunk/clutter/clutter/x11/clutter-backend-x11.c
projects/haf/trunk/clutter/clutter/x11/clutter-x11-texture-pixmap.c
projects/haf/trunk/clutter/debian/changelog
Log:
plug some Coverity memory leaks and add a NULL check
Modified: projects/haf/trunk/clutter/clutter/cogl/common/cogl-bitmap.c
===================================================================
--- projects/haf/trunk/clutter/clutter/cogl/common/cogl-bitmap.c 2009-02-04 14:35:55 UTC (rev 17355)
+++ projects/haf/trunk/clutter/clutter/cogl/common/cogl-bitmap.c 2009-02-04 15:39:11 UTC (rev 17356)
@@ -198,6 +198,7 @@
if (!cogl_pvr_texture_save_pvrtc4( filename, compressed, compressed_size,
width, height))
return FALSE;
-
+
+ g_free (compressed);
return TRUE;
}
Modified: projects/haf/trunk/clutter/clutter/cogl/common/cogl-pvr-texture.c
===================================================================
--- projects/haf/trunk/clutter/clutter/cogl/common/cogl-pvr-texture.c 2009-02-04 14:35:55 UTC (rev 17355)
+++ projects/haf/trunk/clutter/clutter/cogl/common/cogl-pvr-texture.c 2009-02-04 15:39:11 UTC (rev 17356)
@@ -576,6 +576,7 @@
if (read_count != sizeof(PVR_TEXTURE_HEADER))
{
g_warning("%s: File not large enough for header", __FUNCTION__);
+ fclose (texfile);
return 0;
}
@@ -585,7 +586,9 @@
((header.dwPVR >> 16) & 0xFF) != 'R' &&
((header.dwPVR >> 24) & 0xFF) != '!')
{
- g_warning("%s: Invalid PVR magic number 0x%08x", __FUNCTION__, header.dwPVR);
+ g_warning("%s: Invalid PVR magic number 0x%08x", __FUNCTION__,
+ header.dwPVR);
+ fclose (texfile);
return 0;
}
@@ -594,12 +597,16 @@
if (!texture_data)
{
g_warning("%s: Couldn't allocate texture data", __FUNCTION__);
+ fclose (texfile);
return 0;
}
read_count = fread(texture_data, 1, header.dwDataSize, texfile);
if (read_count != header.dwDataSize)
{
- g_warning("%s: File not large enough for image data header describes", __FUNCTION__);
+ g_warning("%s: File not large enough for image data header describes",
+ __FUNCTION__);
+ fclose (texfile);
+ g_free (texture_data);
return 0;
}
@@ -643,10 +650,9 @@
gl_format = GL_ETC1_RGB8_OES;
}
else
- g_warning("%s: Unknown PVR file format 0x%02x", __FUNCTION__, header.dwpfFlags&0xFF);
+ g_warning("%s: Unknown PVR file format 0x%02x", __FUNCTION__,
+ header.dwpfFlags & 0xFF);
-
-
/* load into GL */
GE( glEnable(GL_TEXTURE_2D) );
GE( glGenTextures(1, &tex) );
Modified: projects/haf/trunk/clutter/clutter/x11/clutter-backend-x11.c
===================================================================
--- projects/haf/trunk/clutter/clutter/x11/clutter-backend-x11.c 2009-02-04 14:35:55 UTC (rev 17355)
+++ projects/haf/trunk/clutter/clutter/x11/clutter-backend-x11.c 2009-02-04 15:39:11 UTC (rev 17356)
@@ -664,6 +664,7 @@
backend_singleton->have_xinput = FALSE;
return;
}
+ XFree (ext);
x11b = backend_singleton;
@@ -674,6 +675,7 @@
if (num_devices == 0)
{
backend_singleton->have_xinput = FALSE;
+ XFree (xdevices);
return;
}
Modified: projects/haf/trunk/clutter/clutter/x11/clutter-x11-texture-pixmap.c
===================================================================
--- projects/haf/trunk/clutter/clutter/x11/clutter-x11-texture-pixmap.c 2009-02-04 14:35:55 UTC (rev 17355)
+++ projects/haf/trunk/clutter/clutter/x11/clutter-x11-texture-pixmap.c 2009-02-04 15:39:11 UTC (rev 17356)
@@ -237,6 +237,8 @@
g_warning ("X Error: Failed to setup XShm");
priv->have_shm = TRUE;
+ if (dummy_image)
+ XFree (dummy_image);
return TRUE;
failed_xshmattach:
@@ -785,8 +787,11 @@
priv->pixmap_width, priv->pixmap_height,
AllPlanes,
ZPixmap);
- first_pixel = priv->image->data + priv->image->bytes_per_line * y
+ if (priv->image)
+ first_pixel = priv->image->data + priv->image->bytes_per_line * y
+ x * priv->image->bits_per_pixel/8;
+ else
+ g_warning ("%s: XGetImage() failed", __FUNCTION__);
}
else
{
@@ -812,7 +817,7 @@
priv->pixmap);
/* safe to assume pixmap has gone away? - therefor reset */
clutter_x11_texture_pixmap_set_pixmap (texture, None);
- return;
+ goto free_image_and_return;
}
if (priv->depth == 24)
@@ -837,7 +842,7 @@
pixel_has_alpha = TRUE;
}
else
- return;
+ goto free_image_and_return;
/* For debugging purposes, un comment to simply generate dummy
* pixmap data. (A Green background and Blue cross) */
@@ -898,7 +903,7 @@
if (data_allocated)
g_free (data);
-
+free_image_and_return:
if (priv->have_shm)
XFree (image);
#if 0
Modified: projects/haf/trunk/clutter/debian/changelog
===================================================================
--- projects/haf/trunk/clutter/debian/changelog 2009-02-04 14:35:55 UTC (rev 17355)
+++ projects/haf/trunk/clutter/debian/changelog 2009-02-04 15:39:11 UTC (rev 17356)
@@ -1,6 +1,17 @@
clutter (0.8.2-0maemo16~unreleased) unstable; urgency=low
- * unreleased
+ Plugged leaks found by Coverity:
+ * clutter/cogl/common/cogl-bitmap.c (cogl_bitmap_save_pvrtc4): Free
+ pointer 'compressed'.
+ * clutter/cogl/common/cogl-pvr-texture.c (cogl_pvr_texture_load): fclose()
+ 'texfile' in case of a return because of an error. Free 'texture_data' in
+ one error return.
+ * clutter/x11/clutter-backend-x11.c (_clutter_x11_register_xinput): Free
+ pointer 'ext' and 'xdevices'.
+ * clutter/x11/clutter-x11-texture-pixmap.c (try_alloc_shm): Free
+ dummy_image.
+ (clutter_x11_texture_pixmap_update_area_real): Added NULL check for
+ an XGetImage call. Free 'image' in case of some error cases.
-- Gordon Williams <gordon.williams at collabora.co.uk> Tue, 3 Feb 2009 10:33:19 +0200
- Previous message: [maemo-commits] r17355 - in projects/haf/trunk/hildon-thumbnail: . daemon tests
- Next message: [maemo-commits] r17357 - projects/haf/trunk/dbus/debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
