[gegl] gegl-path: fix potential memory leak



commit 2d0aafb83bc8ca68cb39d0deabf10f036f8a6bab
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 a0a3c4c..d7499a0 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]