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)
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
*num_parasites = return_vals[1].data.d_int32;
|
*num_parasites = return_vals[1].data.d_int32;
|
||||||
parasites = g_new (gchar *, *num_parasites + 1);
|
if (*num_parasites > 0)
|
||||||
for (i = 0; i < *num_parasites; i++)
|
{
|
||||||
parasites[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
parasites = g_new0 (gchar *, *num_parasites + 1);
|
||||||
parasites[i] = NULL;
|
for (i = 0; i < *num_parasites; i++)
|
||||||
|
parasites[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_destroy_params (return_vals, nreturn_vals);
|
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)
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
*num_brushes = return_vals[1].data.d_int32;
|
*num_brushes = return_vals[1].data.d_int32;
|
||||||
brush_list = g_new (gchar *, *num_brushes + 1);
|
if (*num_brushes > 0)
|
||||||
for (i = 0; i < *num_brushes; i++)
|
{
|
||||||
brush_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
brush_list = g_new0 (gchar *, *num_brushes + 1);
|
||||||
brush_list[i] = NULL;
|
for (i = 0; i < *num_brushes; i++)
|
||||||
|
brush_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_destroy_params (return_vals, nreturn_vals);
|
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)
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
*num_buffers = return_vals[1].data.d_int32;
|
*num_buffers = return_vals[1].data.d_int32;
|
||||||
buffer_list = g_new (gchar *, *num_buffers + 1);
|
if (*num_buffers > 0)
|
||||||
for (i = 0; i < *num_buffers; i++)
|
{
|
||||||
buffer_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
buffer_list = g_new0 (gchar *, *num_buffers + 1);
|
||||||
buffer_list[i] = NULL;
|
for (i = 0; i < *num_buffers; i++)
|
||||||
|
buffer_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_destroy_params (return_vals, nreturn_vals);
|
gimp_destroy_params (return_vals, nreturn_vals);
|
||||||
|
|
|
@ -165,10 +165,12 @@ gimp_context_list_paint_methods (gint *num_paint_methods,
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
*num_paint_methods = return_vals[1].data.d_int32;
|
*num_paint_methods = return_vals[1].data.d_int32;
|
||||||
*paint_methods = g_new (gchar *, *num_paint_methods + 1);
|
if (*num_paint_methods > 0)
|
||||||
for (i = 0; i < *num_paint_methods; i++)
|
{
|
||||||
(*paint_methods)[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
*paint_methods = g_new0 (gchar *, *num_paint_methods + 1);
|
||||||
(*paint_methods)[i] = NULL;
|
for (i = 0; i < *num_paint_methods; i++)
|
||||||
|
(*paint_methods)[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_destroy_params (return_vals, nreturn_vals);
|
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)
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
*num_dynamics = return_vals[1].data.d_int32;
|
*num_dynamics = return_vals[1].data.d_int32;
|
||||||
dynamics_list = g_new (gchar *, *num_dynamics + 1);
|
if (*num_dynamics > 0)
|
||||||
for (i = 0; i < *num_dynamics; i++)
|
{
|
||||||
dynamics_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
dynamics_list = g_new0 (gchar *, *num_dynamics + 1);
|
||||||
dynamics_list[i] = NULL;
|
for (i = 0; i < *num_dynamics; i++)
|
||||||
|
dynamics_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_destroy_params (return_vals, nreturn_vals);
|
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)
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
*num_fonts = return_vals[1].data.d_int32;
|
*num_fonts = return_vals[1].data.d_int32;
|
||||||
font_list = g_new (gchar *, *num_fonts + 1);
|
if (*num_fonts > 0)
|
||||||
for (i = 0; i < *num_fonts; i++)
|
{
|
||||||
font_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
font_list = g_new0 (gchar *, *num_fonts + 1);
|
||||||
font_list[i] = NULL;
|
for (i = 0; i < *num_fonts; i++)
|
||||||
|
font_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_destroy_params (return_vals, nreturn_vals);
|
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)
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
*num_gradients = return_vals[1].data.d_int32;
|
*num_gradients = return_vals[1].data.d_int32;
|
||||||
gradient_list = g_new (gchar *, *num_gradients + 1);
|
if (*num_gradients > 0)
|
||||||
for (i = 0; i < *num_gradients; i++)
|
{
|
||||||
gradient_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
gradient_list = g_new0 (gchar *, *num_gradients + 1);
|
||||||
gradient_list[i] = NULL;
|
for (i = 0; i < *num_gradients; i++)
|
||||||
|
gradient_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_destroy_params (return_vals, nreturn_vals);
|
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)
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
*num_parasites = return_vals[1].data.d_int32;
|
*num_parasites = return_vals[1].data.d_int32;
|
||||||
parasites = g_new (gchar *, *num_parasites + 1);
|
if (*num_parasites > 0)
|
||||||
for (i = 0; i < *num_parasites; i++)
|
{
|
||||||
parasites[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
parasites = g_new0 (gchar *, *num_parasites + 1);
|
||||||
parasites[i] = NULL;
|
for (i = 0; i < *num_parasites; i++)
|
||||||
|
parasites[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_destroy_params (return_vals, nreturn_vals);
|
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)
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
*num_parasites = return_vals[1].data.d_int32;
|
*num_parasites = return_vals[1].data.d_int32;
|
||||||
parasites = g_new (gchar *, *num_parasites + 1);
|
if (*num_parasites > 0)
|
||||||
for (i = 0; i < *num_parasites; i++)
|
{
|
||||||
parasites[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
parasites = g_new0 (gchar *, *num_parasites + 1);
|
||||||
parasites[i] = NULL;
|
for (i = 0; i < *num_parasites; i++)
|
||||||
|
parasites[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_destroy_params (return_vals, nreturn_vals);
|
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)
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
*num_palettes = return_vals[1].data.d_int32;
|
*num_palettes = return_vals[1].data.d_int32;
|
||||||
palette_list = g_new (gchar *, *num_palettes + 1);
|
if (*num_palettes > 0)
|
||||||
for (i = 0; i < *num_palettes; i++)
|
{
|
||||||
palette_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
palette_list = g_new0 (gchar *, *num_palettes + 1);
|
||||||
palette_list[i] = NULL;
|
for (i = 0; i < *num_palettes; i++)
|
||||||
|
palette_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_destroy_params (return_vals, nreturn_vals);
|
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)
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
*num_paths = return_vals[1].data.d_int32;
|
*num_paths = return_vals[1].data.d_int32;
|
||||||
path_list = g_new (gchar *, *num_paths + 1);
|
if (*num_paths > 0)
|
||||||
for (i = 0; i < *num_paths; i++)
|
{
|
||||||
path_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
path_list = g_new0 (gchar *, *num_paths + 1);
|
||||||
path_list[i] = NULL;
|
for (i = 0; i < *num_paths; i++)
|
||||||
|
path_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_destroy_params (return_vals, nreturn_vals);
|
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)
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
*num_patterns = return_vals[1].data.d_int32;
|
*num_patterns = return_vals[1].data.d_int32;
|
||||||
pattern_list = g_new (gchar *, *num_patterns + 1);
|
if (*num_patterns > 0)
|
||||||
for (i = 0; i < *num_patterns; i++)
|
{
|
||||||
pattern_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
pattern_list = g_new0 (gchar *, *num_patterns + 1);
|
||||||
pattern_list[i] = NULL;
|
for (i = 0; i < *num_patterns; i++)
|
||||||
|
pattern_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_destroy_params (return_vals, nreturn_vals);
|
gimp_destroy_params (return_vals, nreturn_vals);
|
||||||
|
|
|
@ -162,10 +162,12 @@ gimp_procedural_db_query (const gchar *name,
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
*num_matches = return_vals[1].data.d_int32;
|
*num_matches = return_vals[1].data.d_int32;
|
||||||
*procedure_names = g_new (gchar *, *num_matches + 1);
|
if (*num_matches > 0)
|
||||||
for (i = 0; i < *num_matches; i++)
|
{
|
||||||
(*procedure_names)[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
*procedure_names = g_new0 (gchar *, *num_matches + 1);
|
||||||
(*procedure_names)[i] = NULL;
|
for (i = 0; i < *num_matches; i++)
|
||||||
|
(*procedure_names)[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_destroy_params (return_vals, nreturn_vals);
|
gimp_destroy_params (return_vals, nreturn_vals);
|
||||||
|
|
|
@ -273,10 +273,9 @@ CODE
|
||||||
my $arg = $arg_types{$type};
|
my $arg = $arg_types{$type};
|
||||||
my $var;
|
my $var;
|
||||||
|
|
||||||
my $ch = ""; my $cf = ""; my $numvarplus = "";
|
my $ch = "";
|
||||||
if ($type =~ /stringarray/) {
|
my $cf = "";
|
||||||
$numvarplus = ' + 1';
|
|
||||||
}
|
|
||||||
if ($type =~ /^string(array)?/) {
|
if ($type =~ /^string(array)?/) {
|
||||||
$ch = 'g_strdup (';
|
$ch = 'g_strdup (';
|
||||||
$cf = ')';
|
$cf = ')';
|
||||||
|
@ -321,9 +320,23 @@ CODE
|
||||||
my $numvar = '*' . $_->{array}->{name};
|
my $numvar = '*' . $_->{array}->{name};
|
||||||
$numvar = "num_$_->{name}" if exists $_->{array}->{no_lib};
|
$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;
|
$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
|
NEW
|
||||||
for (i = 0; i < $numvar; i++)
|
for (i = 0; i < $numvar; i++)
|
||||||
$dh$_->{name}$df\[i] = ${ch}return_vals[$argc].data.d_$type\[i]${cf};
|
$dh$_->{name}$df\[i] = ${ch}return_vals[$argc].data.d_$type\[i]${cf};
|
||||||
|
@ -332,11 +345,7 @@ CP1
|
||||||
return_vals[$argc].data.d_$type,
|
return_vals[$argc].data.d_$type,
|
||||||
$numvar * sizeof ($datatype));
|
$numvar * sizeof ($datatype));
|
||||||
CP2
|
CP2
|
||||||
if ($type =~ /stringarray/) {
|
}
|
||||||
$return_marshal .= <<FINISH
|
|
||||||
$dh$_->{name}$df\[i] = NULL;
|
|
||||||
FINISH
|
|
||||||
}
|
|
||||||
$out->{headers} = "#include <string.h>\n" unless ($ch || $cf);
|
$out->{headers} = "#include <string.h>\n" unless ($ch || $cf);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue