[gimp] app: allocate GimpCurve's points with g_new0() and not just g_new()



commit 4c58386ead2d79c2fadaddce4d4db2fb67d15165
Author: Michael Natterer <mitch gimp org>
Date:   Wed Jun 26 16:24:29 2019 +0200

    app: allocate GimpCurve's points with g_new0() and not just g_new()
    
    so gimp_curve_equal() doesn't fail on random uninitialized padding
    bits. Fixes finding previously used settings in the curves tool (they
    were piling up just by re-applying a previously used setting).

 app/core/gimpcurve.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/app/core/gimpcurve.c b/app/core/gimpcurve.c
index f7daa0b334..10b2be6bda 100644
--- a/app/core/gimpcurve.c
+++ b/app/core/gimpcurve.c
@@ -269,7 +269,7 @@ gimp_curve_set_property (GObject      *object,
         length = gimp_value_array_length (array) / 2;
 
         n_points = 0;
-        points   = g_new (GimpCurvePoint, length);
+        points   = g_new0 (GimpCurvePoint, length);
 
         for (i = 0; i < length; i++)
           {
@@ -325,7 +325,7 @@ gimp_curve_set_property (GObject      *object,
 
         length = gimp_value_array_length (array);
 
-        points = g_new (GimpCurvePoint, length);
+        points = g_new0 (GimpCurvePoint, length);
 
         for (i = 0; i < length; i++)
           {
@@ -686,7 +686,7 @@ gimp_curve_reset (GimpCurve *curve,
   g_free (curve->points);
 
   curve->n_points = 2;
-  curve->points   = g_new (GimpCurvePoint, 2);
+  curve->points   = g_new0 (GimpCurvePoint, 2);
 
   curve->points[0].x    = 0.0;
   curve->points[0].y    = 0.0;
@@ -737,7 +737,7 @@ gimp_curve_set_curve_type (GimpCurve     *curve,
            *  points
            */
           curve->n_points = 9;
-          curve->points   = g_new (GimpCurvePoint, 9);
+          curve->points   = g_new0 (GimpCurvePoint, 9);
 
           for (i = 0; i < curve->n_points; i++)
             {
@@ -901,7 +901,7 @@ gimp_curve_add_point (GimpCurve *curve,
         break;
     }
 
-  points = g_new (GimpCurvePoint, curve->n_points + 1);
+  points = g_new0 (GimpCurvePoint, curve->n_points + 1);
 
   memcpy (points,         curve->points,
           point * sizeof (GimpCurvePoint));
@@ -935,7 +935,7 @@ gimp_curve_delete_point (GimpCurve *curve,
   g_return_if_fail (GIMP_IS_CURVE (curve));
   g_return_if_fail (point >= 0 && point < curve->n_points);
 
-  points = g_new (GimpCurvePoint, curve->n_points - 1);
+  points = g_new0 (GimpCurvePoint, curve->n_points - 1);
 
   memcpy (points,         curve->points,
           point * sizeof (GimpCurvePoint));


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