[dia] [scan-build] Fix potential memory leak
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] [scan-build] Fix potential memory leak
- Date: Fri, 5 Sep 2014 15:48:41 +0000 (UTC)
commit 0752d3219e9d36746939f5dc0e0d595119025a3c
Author: Hans Breuer <hans breuer org>
Date: Fri Sep 5 13:55:36 2014 +0200
[scan-build] Fix potential memory leak
Value stored to 'renderer' during its initialization is never read
File: /home/hb/from-git/dia/lib/diaimportrenderer.c
Line: 142
A user of DiaImportRenderer which would not call
dia_import_renderer_get_objects() after importing the data would
have leaked all the objects.
lib/diaimportrenderer.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/lib/diaimportrenderer.c b/lib/diaimportrenderer.c
index 2adffcf..980ff11 100644
--- a/lib/diaimportrenderer.c
+++ b/lib/diaimportrenderer.c
@@ -140,8 +140,14 @@ static void
renderer_finalize (GObject *object)
{
DiaRenderer *renderer = DIA_RENDERER (object);
+ DiaImportRenderer *self = DIA_IMPORT_RENDERER (renderer);
- /* XXX: anything to destroy */
+ /* anything more to destroy? */
+ if (self->objects) {
+ /* if no one called dia_import_renderer_get_objects() */
+ destroy_object_list(self->objects);
+ self->objects = NULL;
+ }
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -392,8 +398,8 @@ fill_arc (DiaRenderer *renderer, Point *center,
real width, real height, real angle1, real angle2,
Color *color)
{
- DiaImportRenderer *self = DIA_IMPORT_RENDERER (renderer);
#if 0 /* does not work till 'Standard - Arc' supports filling */
+ DiaImportRenderer *self = DIA_IMPORT_RENDERER (renderer);
DiaObject *object = _make_arc (center, width, height, angle1, angle2);
_apply_style (self, object, color, NULL, 0.0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]