mirror of https://github.com/GNOME/gimp.git
pdb: return NULL for string arrays with zero elements
In e61b1f76
things were changed to return string arrays that can be
freed with g_strfreev(), but that returned a one-element array
containing a NULL pointer for zero-length arrays. Fix the code
to return NULL again for zero-length arrays. See bug #751584.
This commit is contained in:
parent
d7b2d1c372
commit
02d1192753
|
@ -218,10 +218,12 @@ gimp_get_parasite_list (gint *num_parasites)
|
|||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
*num_parasites = return_vals[1].data.d_int32;
|
||||
parasites = g_new (gchar *, *num_parasites + 1);
|
||||
if (*num_parasites > 0)
|
||||
{
|
||||
parasites = g_new0 (gchar *, *num_parasites + 1);
|
||||
for (i = 0; i < *num_parasites; i++)
|
||||
parasites[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||
parasites[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
|
|
@ -97,10 +97,12 @@ gimp_brushes_get_list (const gchar *filter,
|
|||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
*num_brushes = return_vals[1].data.d_int32;
|
||||
brush_list = g_new (gchar *, *num_brushes + 1);
|
||||
if (*num_brushes > 0)
|
||||
{
|
||||
brush_list = g_new0 (gchar *, *num_brushes + 1);
|
||||
for (i = 0; i < *num_brushes; i++)
|
||||
brush_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||
brush_list[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
|
|
@ -68,10 +68,12 @@ gimp_buffers_get_list (const gchar *filter,
|
|||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
*num_buffers = return_vals[1].data.d_int32;
|
||||
buffer_list = g_new (gchar *, *num_buffers + 1);
|
||||
if (*num_buffers > 0)
|
||||
{
|
||||
buffer_list = g_new0 (gchar *, *num_buffers + 1);
|
||||
for (i = 0; i < *num_buffers; i++)
|
||||
buffer_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||
buffer_list[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
|
|
@ -165,10 +165,12 @@ gimp_context_list_paint_methods (gint *num_paint_methods,
|
|||
if (success)
|
||||
{
|
||||
*num_paint_methods = return_vals[1].data.d_int32;
|
||||
*paint_methods = g_new (gchar *, *num_paint_methods + 1);
|
||||
if (*num_paint_methods > 0)
|
||||
{
|
||||
*paint_methods = g_new0 (gchar *, *num_paint_methods + 1);
|
||||
for (i = 0; i < *num_paint_methods; i++)
|
||||
(*paint_methods)[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||
(*paint_methods)[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
|
|
@ -99,10 +99,12 @@ gimp_dynamics_get_list (const gchar *filter,
|
|||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
*num_dynamics = return_vals[1].data.d_int32;
|
||||
dynamics_list = g_new (gchar *, *num_dynamics + 1);
|
||||
if (*num_dynamics > 0)
|
||||
{
|
||||
dynamics_list = g_new0 (gchar *, *num_dynamics + 1);
|
||||
for (i = 0; i < *num_dynamics; i++)
|
||||
dynamics_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||
dynamics_list[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
|
|
@ -94,10 +94,12 @@ gimp_fonts_get_list (const gchar *filter,
|
|||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
*num_fonts = return_vals[1].data.d_int32;
|
||||
font_list = g_new (gchar *, *num_fonts + 1);
|
||||
if (*num_fonts > 0)
|
||||
{
|
||||
font_list = g_new0 (gchar *, *num_fonts + 1);
|
||||
for (i = 0; i < *num_fonts; i++)
|
||||
font_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||
font_list[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
|
|
@ -97,10 +97,12 @@ gimp_gradients_get_list (const gchar *filter,
|
|||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
*num_gradients = return_vals[1].data.d_int32;
|
||||
gradient_list = g_new (gchar *, *num_gradients + 1);
|
||||
if (*num_gradients > 0)
|
||||
{
|
||||
gradient_list = g_new0 (gchar *, *num_gradients + 1);
|
||||
for (i = 0; i < *num_gradients; i++)
|
||||
gradient_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||
gradient_list[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
|
|
@ -2923,10 +2923,12 @@ gimp_image_get_parasite_list (gint32 image_ID,
|
|||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
*num_parasites = return_vals[1].data.d_int32;
|
||||
parasites = g_new (gchar *, *num_parasites + 1);
|
||||
if (*num_parasites > 0)
|
||||
{
|
||||
parasites = g_new0 (gchar *, *num_parasites + 1);
|
||||
for (i = 0; i < *num_parasites; i++)
|
||||
parasites[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||
parasites[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
|
|
@ -1006,10 +1006,12 @@ gimp_item_get_parasite_list (gint32 item_ID,
|
|||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
*num_parasites = return_vals[1].data.d_int32;
|
||||
parasites = g_new (gchar *, *num_parasites + 1);
|
||||
if (*num_parasites > 0)
|
||||
{
|
||||
parasites = g_new0 (gchar *, *num_parasites + 1);
|
||||
for (i = 0; i < *num_parasites; i++)
|
||||
parasites[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||
parasites[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
|
|
@ -95,10 +95,12 @@ gimp_palettes_get_list (const gchar *filter,
|
|||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
*num_palettes = return_vals[1].data.d_int32;
|
||||
palette_list = g_new (gchar *, *num_palettes + 1);
|
||||
if (*num_palettes > 0)
|
||||
{
|
||||
palette_list = g_new0 (gchar *, *num_palettes + 1);
|
||||
for (i = 0; i < *num_palettes; i++)
|
||||
palette_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||
palette_list[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
|
|
@ -65,10 +65,12 @@ gimp_path_list (gint32 image_ID,
|
|||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
*num_paths = return_vals[1].data.d_int32;
|
||||
path_list = g_new (gchar *, *num_paths + 1);
|
||||
if (*num_paths > 0)
|
||||
{
|
||||
path_list = g_new0 (gchar *, *num_paths + 1);
|
||||
for (i = 0; i < *num_paths; i++)
|
||||
path_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||
path_list[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
|
|
@ -97,10 +97,12 @@ gimp_patterns_get_list (const gchar *filter,
|
|||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
*num_patterns = return_vals[1].data.d_int32;
|
||||
pattern_list = g_new (gchar *, *num_patterns + 1);
|
||||
if (*num_patterns > 0)
|
||||
{
|
||||
pattern_list = g_new0 (gchar *, *num_patterns + 1);
|
||||
for (i = 0; i < *num_patterns; i++)
|
||||
pattern_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||
pattern_list[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
|
|
@ -162,10 +162,12 @@ gimp_procedural_db_query (const gchar *name,
|
|||
if (success)
|
||||
{
|
||||
*num_matches = return_vals[1].data.d_int32;
|
||||
*procedure_names = g_new (gchar *, *num_matches + 1);
|
||||
if (*num_matches > 0)
|
||||
{
|
||||
*procedure_names = g_new0 (gchar *, *num_matches + 1);
|
||||
for (i = 0; i < *num_matches; i++)
|
||||
(*procedure_names)[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||
(*procedure_names)[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
|
|
@ -273,10 +273,9 @@ CODE
|
|||
my $arg = $arg_types{$type};
|
||||
my $var;
|
||||
|
||||
my $ch = ""; my $cf = ""; my $numvarplus = "";
|
||||
if ($type =~ /stringarray/) {
|
||||
$numvarplus = ' + 1';
|
||||
}
|
||||
my $ch = "";
|
||||
my $cf = "";
|
||||
|
||||
if ($type =~ /^string(array)?/) {
|
||||
$ch = 'g_strdup (';
|
||||
$cf = ')';
|
||||
|
@ -321,9 +320,23 @@ CODE
|
|||
my $numvar = '*' . $_->{array}->{name};
|
||||
$numvar = "num_$_->{name}" if exists $_->{array}->{no_lib};
|
||||
|
||||
$return_marshal .= <<NEW . (($ch || $cf) ? <<CP1 : <<CP2);
|
||||
$return_marshal .= <<NUMVAR;
|
||||
$numvar = return_vals[$numpos].data.d_$numtype;
|
||||
$var = g_new ($datatype, $numvar$numvarplus);
|
||||
NUMVAR
|
||||
|
||||
if ($type =~ /stringarray/) {
|
||||
$return_marshal .= <<CP;
|
||||
if ($numvar > 0)
|
||||
{
|
||||
$var = g_new0 ($datatype, $numvar + 1);
|
||||
for (i = 0; i < $numvar; i++)
|
||||
$dh$_->{name}$df\[i] = ${ch}return_vals[$argc].data.d_$type\[i]${cf};
|
||||
}
|
||||
CP
|
||||
}
|
||||
else {
|
||||
$return_marshal .= <<NEW . (($ch || $cf) ? <<CP1 : <<CP2);
|
||||
$var = g_new ($datatype, $numvar);
|
||||
NEW
|
||||
for (i = 0; i < $numvar; i++)
|
||||
$dh$_->{name}$df\[i] = ${ch}return_vals[$argc].data.d_$type\[i]${cf};
|
||||
|
@ -332,10 +345,6 @@ CP1
|
|||
return_vals[$argc].data.d_$type,
|
||||
$numvar * sizeof ($datatype));
|
||||
CP2
|
||||
if ($type =~ /stringarray/) {
|
||||
$return_marshal .= <<FINISH
|
||||
$dh$_->{name}$df\[i] = NULL;
|
||||
FINISH
|
||||
}
|
||||
$out->{headers} = "#include <string.h>\n" unless ($ch || $cf);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue