[gimp] libgimp: deal with NULL arrays in _gimp_value_to_gp_param()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimp: deal with NULL arrays in _gimp_value_to_gp_param()
- Date: Tue, 13 Aug 2019 20:53:30 +0000 (UTC)
commit 35fb6ca71634dcb04dc4ce8b25ff035bbb5187e8
Author: Michael Natterer <mitch gimp org>
Date: Tue Aug 13 22:52:19 2019 +0200
libgimp: deal with NULL arrays in _gimp_value_to_gp_param()
How did this not crash even once before in my tests...
libgimp/gimpgpparams-body.c | 40 +++++++++++++++++++++++++++-------------
1 file changed, 27 insertions(+), 13 deletions(-)
---
diff --git a/libgimp/gimpgpparams-body.c b/libgimp/gimpgpparams-body.c
index 165215c7cf..21637dc247 100644
--- a/libgimp/gimpgpparams-body.c
+++ b/libgimp/gimpgpparams-body.c
@@ -517,30 +517,44 @@ _gimp_value_to_gp_param (const GValue *value,
{
GimpArray *array = g_value_get_boxed (value);
- param->param_type = GP_PARAM_TYPE_ARRAY;
+ if (array)
+ {
+ param->param_type = GP_PARAM_TYPE_ARRAY;
- param->data.d_array.size = array->length;
+ param->data.d_array.size = array->length;
- if (full_copy)
- param->data.d_array.data = g_memdup (array->data,
- array->length);
+ if (full_copy)
+ param->data.d_array.data = g_memdup (array->data,
+ array->length);
+ else
+ param->data.d_array.data = array->data;
+ }
else
- param->data.d_array.data = array->data;
+ {
+ param->data.d_array.data = NULL;
+ }
}
else if (GIMP_VALUE_HOLDS_STRING_ARRAY (value))
{
GimpArray *array = g_value_get_boxed (value);
- param->param_type = GP_PARAM_TYPE_STRING_ARRAY;
+ if (array)
+ {
+ param->param_type = GP_PARAM_TYPE_STRING_ARRAY;
- param->data.d_string_array.size = array->length;
+ param->data.d_string_array.size = array->length;
- if (full_copy)
- param->data.d_string_array.data =
- gimp_value_dup_string_array (value);
+ if (full_copy)
+ param->data.d_string_array.data =
+ gimp_value_dup_string_array (value);
+ else
+ param->data.d_string_array.data =
+ (gchar **) gimp_value_get_string_array (value);
+ }
else
- param->data.d_string_array.data =
- (gchar **) gimp_value_get_string_array (value);
+ {
+ param->data.d_string_array.data = NULL;
+ }
}
else if (GIMP_VALUE_HOLDS_DISPLAY_ID (value) ||
GIMP_VALUE_HOLDS_IMAGE_ID (value) ||
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]