[gimp] libgimpbase: NULL-terminate the result of gimp_value_dup_string_array()



commit 9e50f1ed8f47b109077e5fcd85b4d43f500fb3ca
Author: Michael Natterer <mitch gimp org>
Date:   Tue Jul 30 01:38:07 2019 +0200

    libgimpbase: NULL-terminate the result of gimp_value_dup_string_array()
    
    so it can be free'd with g_strfreev().

 libgimpbase/gimpparamspecs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/libgimpbase/gimpparamspecs.c b/libgimpbase/gimpparamspecs.c
index c03746f9d8..eae571153b 100644
--- a/libgimpbase/gimpparamspecs.c
+++ b/libgimpbase/gimpparamspecs.c
@@ -1165,9 +1165,9 @@ gimp_string_array_new (const gchar **data,
 
   array = g_slice_new0 (GimpArray);
 
-  if (! static_data)
+  if (! static_data && data)
     {
-      gchar **tmp = g_new (gchar *, length);
+      gchar **tmp = g_new0 (gchar *, length + 1);
       gint    i;
 
       for (i = 0; i < length; i++)
@@ -1361,7 +1361,7 @@ gimp_value_dup_string_array (const GValue *value)
 
   if (array)
     {
-      gchar **ret = g_memdup (array->data, array->length * sizeof (gchar *));
+      gchar **ret = g_memdup (array->data, (array->length + 1) * sizeof (gchar *));
       gint    i;
 
       for (i = 0; i < array->length; i++)


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