[gegl/soc-2011-warp] gegl-path: fix potential memory leak



commit 23509ccd62e80e4f38f1c091593a7fe8e1fe00bc
Author: Michael Murà <batolettre gmail com>
Date:   Wed Aug 24 01:12:39 2011 +0200

    gegl-path: fix potential memory leak

 gegl/property-types/gegl-path.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/gegl/property-types/gegl-path.c b/gegl/property-types/gegl-path.c
index f4cf7dd..f483ad5 100644
--- a/gegl/property-types/gegl-path.c
+++ b/gegl/property-types/gegl-path.c
@@ -438,17 +438,20 @@ gegl_path_closest_point (GeglPath *path,
   gint   closest_val = 0;
   gdouble  *samples_x;
   gdouble  *samples_y;
-  n = ceil(length);
-  samples_x = g_malloc (sizeof (gdouble)* n);
-  samples_y = g_malloc (sizeof (gdouble)* n);
 
   if (length == 0)
     {
       if (node_pos_before)
-        *node_pos_before = 0;
+        {
+          *node_pos_before = 0;
+        }
       return 0.0;
     }
 
+  n = ceil(length);
+  samples_x = g_malloc (sizeof (gdouble)* n);
+  samples_y = g_malloc (sizeof (gdouble)* n);
+
   gegl_path_calc_values (path, n, samples_x, samples_y);
 
   for (i=0;i<n;i++)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]