app, libgimp, pdb: fix other int sizes.

Avoid the stack smashing bug from yesterday in other functions.
Additionally to fixing other functions, do not cast the pointer to size
in the PDB generation scripts so that we can quickly spot such bugs in
the future, through compilation time warnings, instead of hiding them.
This commit is contained in:
Jehan 2024-10-28 10:46:17 +01:00
parent a350efeeb1
commit ea5824ebd7
16 changed files with 47 additions and 47 deletions

View file

@ -781,7 +781,7 @@ context_set_line_dash_pattern_invoker (GimpProcedure *procedure,
gsize num_dashes;
const gdouble *dashes;
dashes = gimp_value_get_float_array (gimp_value_array_index (args, 0), (gsize *) &num_dashes);
dashes = gimp_value_get_float_array (gimp_value_array_index (args, 0), &num_dashes);
if (success)
{

View file

@ -207,12 +207,12 @@ drawable_curves_explicit_invoker (GimpProcedure *procedure,
gboolean success = TRUE;
GimpDrawable *drawable;
gint channel;
gint num_values;
gsize num_values;
const gdouble *values;
drawable = g_value_get_object (gimp_value_array_index (args, 0));
channel = g_value_get_enum (gimp_value_array_index (args, 1));
values = gimp_value_get_float_array (gimp_value_array_index (args, 2), (gsize *) &num_values);
values = gimp_value_get_float_array (gimp_value_array_index (args, 2), &num_values);
if (success)
{
@ -255,12 +255,12 @@ drawable_curves_spline_invoker (GimpProcedure *procedure,
gboolean success = TRUE;
GimpDrawable *drawable;
gint channel;
gint num_points;
gsize num_points;
const gdouble *points;
drawable = g_value_get_object (gimp_value_array_index (args, 0));
channel = g_value_get_enum (gimp_value_array_index (args, 1));
points = gimp_value_get_float_array (gimp_value_array_index (args, 2), (gsize *) &num_points);
points = gimp_value_get_float_array (gimp_value_array_index (args, 2), &num_points);
if (success)
{

View file

@ -225,14 +225,14 @@ gradient_get_custom_samples_invoker (GimpProcedure *procedure,
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpGradient *gradient;
gint num_samples;
gsize num_samples;
const gdouble *positions;
gboolean reverse;
gsize num_color_samples = 0;
gdouble *color_samples = NULL;
gradient = g_value_get_object (gimp_value_array_index (args, 0));
positions = gimp_value_get_float_array (gimp_value_array_index (args, 1), (gsize *) &num_samples);
positions = gimp_value_get_float_array (gimp_value_array_index (args, 1), &num_samples);
reverse = g_value_get_boolean (gimp_value_array_index (args, 2));
if (success)

View file

@ -295,7 +295,7 @@ image_select_polygon_invoker (GimpProcedure *procedure,
image = g_value_get_object (gimp_value_array_index (args, 0));
operation = g_value_get_enum (gimp_value_array_index (args, 1));
segs = gimp_value_get_float_array (gimp_value_array_index (args, 2), (gsize *) &num_segs);
segs = gimp_value_get_float_array (gimp_value_array_index (args, 2), &num_segs);
if (success)
{

View file

@ -118,7 +118,7 @@ airbrush_invoker (GimpProcedure *procedure,
drawable = g_value_get_object (gimp_value_array_index (args, 0));
pressure = g_value_get_double (gimp_value_array_index (args, 1));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 2), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 2), &num_strokes);
if (success)
{
@ -164,7 +164,7 @@ airbrush_default_invoker (GimpProcedure *procedure,
const gdouble *strokes;
drawable = g_value_get_object (gimp_value_array_index (args, 0));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), &num_strokes);
if (success)
{
@ -214,7 +214,7 @@ clone_invoker (GimpProcedure *procedure,
clone_type = g_value_get_enum (gimp_value_array_index (args, 2));
src_x = g_value_get_double (gimp_value_array_index (args, 3));
src_y = g_value_get_double (gimp_value_array_index (args, 4));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 5), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 5), &num_strokes);
if (success)
{
@ -267,7 +267,7 @@ clone_default_invoker (GimpProcedure *procedure,
const gdouble *strokes;
drawable = g_value_get_object (gimp_value_array_index (args, 0));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), &num_strokes);
if (success)
{
@ -313,7 +313,7 @@ convolve_invoker (GimpProcedure *procedure,
drawable = g_value_get_object (gimp_value_array_index (args, 0));
pressure = g_value_get_double (gimp_value_array_index (args, 1));
convolve_type = g_value_get_enum (gimp_value_array_index (args, 2));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 3), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 3), &num_strokes);
if (success)
{
@ -360,7 +360,7 @@ convolve_default_invoker (GimpProcedure *procedure,
const gdouble *strokes;
drawable = g_value_get_object (gimp_value_array_index (args, 0));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), &num_strokes);
if (success)
{
@ -408,7 +408,7 @@ dodgeburn_invoker (GimpProcedure *procedure,
exposure = g_value_get_double (gimp_value_array_index (args, 1));
dodgeburn_type = g_value_get_enum (gimp_value_array_index (args, 2));
dodgeburn_mode = g_value_get_enum (gimp_value_array_index (args, 3));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 4), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 4), &num_strokes);
if (success)
{
@ -456,7 +456,7 @@ dodgeburn_default_invoker (GimpProcedure *procedure,
const gdouble *strokes;
drawable = g_value_get_object (gimp_value_array_index (args, 0));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), &num_strokes);
if (success)
{
@ -500,7 +500,7 @@ eraser_invoker (GimpProcedure *procedure,
gint method;
drawable = g_value_get_object (gimp_value_array_index (args, 0));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), &num_strokes);
hardness = g_value_get_enum (gimp_value_array_index (args, 2));
method = g_value_get_enum (gimp_value_array_index (args, 3));
@ -549,7 +549,7 @@ eraser_default_invoker (GimpProcedure *procedure,
const gdouble *strokes;
drawable = g_value_get_object (gimp_value_array_index (args, 0));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), &num_strokes);
if (success)
{
@ -597,7 +597,7 @@ heal_invoker (GimpProcedure *procedure,
src_drawable = g_value_get_object (gimp_value_array_index (args, 1));
src_x = g_value_get_double (gimp_value_array_index (args, 2));
src_y = g_value_get_double (gimp_value_array_index (args, 3));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 4), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 4), &num_strokes);
if (success)
{
@ -649,7 +649,7 @@ heal_default_invoker (GimpProcedure *procedure,
const gdouble *strokes;
drawable = g_value_get_object (gimp_value_array_index (args, 0));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), &num_strokes);
if (success)
{
@ -695,7 +695,7 @@ paintbrush_invoker (GimpProcedure *procedure,
drawable = g_value_get_object (gimp_value_array_index (args, 0));
fade_out = g_value_get_double (gimp_value_array_index (args, 1));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 2), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 2), &num_strokes);
method = g_value_get_enum (gimp_value_array_index (args, 3));
gradient_length = g_value_get_double (gimp_value_array_index (args, 4));
@ -775,7 +775,7 @@ paintbrush_default_invoker (GimpProcedure *procedure,
const gdouble *strokes;
drawable = g_value_get_object (gimp_value_array_index (args, 0));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), &num_strokes);
if (success)
{
@ -817,7 +817,7 @@ pencil_invoker (GimpProcedure *procedure,
const gdouble *strokes;
drawable = g_value_get_object (gimp_value_array_index (args, 0));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), &num_strokes);
if (success)
{
@ -861,7 +861,7 @@ smudge_invoker (GimpProcedure *procedure,
drawable = g_value_get_object (gimp_value_array_index (args, 0));
pressure = g_value_get_double (gimp_value_array_index (args, 1));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 2), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 2), &num_strokes);
if (success)
{
@ -907,7 +907,7 @@ smudge_default_invoker (GimpProcedure *procedure,
const gdouble *strokes;
drawable = g_value_get_object (gimp_value_array_index (args, 0));
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), (gsize *) &num_strokes);
strokes = gimp_value_get_float_array (gimp_value_array_index (args, 1), &num_strokes);
if (success)
{

View file

@ -730,7 +730,7 @@ path_stroke_new_from_points_invoker (GimpProcedure *procedure,
path = g_value_get_object (gimp_value_array_index (args, 0));
type = g_value_get_enum (gimp_value_array_index (args, 1));
controlpoints = gimp_value_get_float_array (gimp_value_array_index (args, 2), (gsize *) &num_points);
controlpoints = gimp_value_get_float_array (gimp_value_array_index (args, 2), &num_points);
closed = g_value_get_boolean (gimp_value_array_index (args, 3));
if (success)

View file

@ -1138,11 +1138,11 @@ plug_in_convmatrix_invoker (GimpProcedure *procedure,
gint bmode;
drawable = g_value_get_object (gimp_value_array_index (args, 2));
matrix = gimp_value_get_float_array (gimp_value_array_index (args, 3), (gsize *) &argc_matrix);
matrix = gimp_value_get_float_array (gimp_value_array_index (args, 3), &argc_matrix);
alpha_alg = g_value_get_boolean (gimp_value_array_index (args, 4));
divisor = g_value_get_double (gimp_value_array_index (args, 5));
offset = g_value_get_double (gimp_value_array_index (args, 6));
channels = gimp_value_get_int32_array (gimp_value_array_index (args, 7), (gsize *) &argc_channels);
channels = gimp_value_get_int32_array (gimp_value_array_index (args, 7), &argc_channels);
bmode = g_value_get_int (gimp_value_array_index (args, 8));
if (success)

View file

@ -1159,7 +1159,7 @@ gimp_context_get_line_dash_pattern (gsize *num_dashes,
if (success)
{
*dashes = GIMP_VALUES_DUP_FLOAT_ARRAY (return_vals, 1, (gsize *) num_dashes);
*dashes = GIMP_VALUES_DUP_FLOAT_ARRAY (return_vals, 1, num_dashes);
}
gimp_value_array_unref (return_vals);

View file

@ -207,7 +207,7 @@ gimp_drawable_colorize_hsl (GimpDrawable *drawable,
gboolean
gimp_drawable_curves_explicit (GimpDrawable *drawable,
GimpHistogramChannel channel,
gint num_values,
gsize num_values,
const gdouble *values)
{
GimpValueArray *args;
@ -260,7 +260,7 @@ gimp_drawable_curves_explicit (GimpDrawable *drawable,
gboolean
gimp_drawable_curves_spline (GimpDrawable *drawable,
GimpHistogramChannel channel,
gint num_points,
gsize num_points,
const gdouble *points)
{
GimpValueArray *args;

View file

@ -47,11 +47,11 @@ gboolean gimp_drawable_colorize_hsl (GimpDrawable *drawable,
gdouble lightness);
gboolean gimp_drawable_curves_explicit (GimpDrawable *drawable,
GimpHistogramChannel channel,
gint num_values,
gsize num_values,
const gdouble *values);
gboolean gimp_drawable_curves_spline (GimpDrawable *drawable,
GimpHistogramChannel channel,
gint num_points,
gsize num_points,
const gdouble *points);
gboolean gimp_drawable_extract_component (GimpDrawable *drawable,
gint component,

View file

@ -195,7 +195,7 @@ gimp_gradient_get_uniform_samples (GimpGradient *gradient,
if (success)
{
*color_samples = GIMP_VALUES_DUP_FLOAT_ARRAY (return_vals, 1, (gsize *) num_color_samples);
*color_samples = GIMP_VALUES_DUP_FLOAT_ARRAY (return_vals, 1, num_color_samples);
}
gimp_value_array_unref (return_vals);
@ -225,7 +225,7 @@ gimp_gradient_get_uniform_samples (GimpGradient *gradient,
**/
gboolean
gimp_gradient_get_custom_samples (GimpGradient *gradient,
gint num_samples,
gsize num_samples,
const gdouble *positions,
gboolean reverse,
gsize *num_color_samples,
@ -256,7 +256,7 @@ gimp_gradient_get_custom_samples (GimpGradient *gradient,
if (success)
{
*color_samples = GIMP_VALUES_DUP_FLOAT_ARRAY (return_vals, 1, (gsize *) num_color_samples);
*color_samples = GIMP_VALUES_DUP_FLOAT_ARRAY (return_vals, 1, num_color_samples);
}
gimp_value_array_unref (return_vals);

View file

@ -41,7 +41,7 @@ gboolean gimp_gradient_get_uniform_samples (GimpGradient
gsize *num_color_samples,
gdouble **color_samples);
gboolean gimp_gradient_get_custom_samples (GimpGradient *gradient,
gint num_samples,
gsize num_samples,
const gdouble *positions,
gboolean reverse,
gsize *num_color_samples,

View file

@ -191,7 +191,7 @@ gimp_path_get_strokes (GimpPath *path,
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
{
stroke_ids = GIMP_VALUES_DUP_INT32_ARRAY (return_vals, 1, (gsize *) num_strokes);
stroke_ids = GIMP_VALUES_DUP_INT32_ARRAY (return_vals, 1, num_strokes);
}
gimp_value_array_unref (return_vals);
@ -701,7 +701,7 @@ gimp_path_stroke_get_points (GimpPath *path,
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
{
type = GIMP_VALUES_GET_ENUM (return_vals, 1);
*controlpoints = GIMP_VALUES_DUP_FLOAT_ARRAY (return_vals, 2, (gsize *) num_points);
*controlpoints = GIMP_VALUES_DUP_FLOAT_ARRAY (return_vals, 2, num_points);
*closed = GIMP_VALUES_GET_BOOLEAN (return_vals, 3);
}
@ -808,7 +808,7 @@ gimp_path_stroke_interpolate (GimpPath *path,
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
{
coords = GIMP_VALUES_DUP_FLOAT_ARRAY (return_vals, 1, (gsize *) num_coords);
coords = GIMP_VALUES_DUP_FLOAT_ARRAY (return_vals, 1, num_coords);
*closed = GIMP_VALUES_GET_BOOLEAN (return_vals, 2);
}

View file

@ -199,7 +199,7 @@ HELP
desc => 'The channel to modify' },
{ name => 'values', type => 'floatarray',
desc => 'The explicit curve',
array => { name => 'num_values', type => '256 <= int32 <= 2096',
array => { name => 'num_values', type => '256 <= size <= 2096',
desc => 'The number of values in the new curve' } }
);
@ -257,7 +257,7 @@ HELP
{ name => 'points', type => 'floatarray',
desc => 'The spline control points: { cp1.x, cp1.y, cp2.x, cp2.y,
... }',
array => { name => 'num_points', type => '4 <= int32 <= 2048',
array => { name => 'num_points', type => '4 <= size <= 2048',
desc => 'The number of values in the control point array' }
}
);

View file

@ -219,7 +219,7 @@ HELP
${gradient_arg_spec},
{ name => 'positions', type => 'floatarray',
desc => 'The list of positions to sample along the gradient',
array => { name => 'num_samples', type => '1 <= int32',
array => { name => 'num_samples', type => '1 <= size',
desc => 'The number of samples to take' } },
{ name => 'reverse', type => 'boolean',
desc => 'Use the reverse gradient' }

View file

@ -89,8 +89,8 @@ package Gimp::CodeGen::pdb;
init_value => 'NULL',
in_annotate => '(element-type gint32)',
out_annotate => '(element-type gint32) (transfer full)',
get_value_func => '$var = gimp_value_get_int32_array ($value, (gsize *) &$var_len)',
dup_value_func => '$var = GIMP_VALUES_DUP_INT32_ARRAY ($value, (gsize *) $var_len)',
get_value_func => '$var = gimp_value_get_int32_array ($value, &$var_len)',
dup_value_func => '$var = GIMP_VALUES_DUP_INT32_ARRAY ($value, $var_len)',
set_value_func => 'gimp_value_set_int32_array ($value, $var, $var_len)',
take_value_func => 'gimp_value_take_int32_array ($value, $var, $var_len)' },
@ -102,8 +102,8 @@ package Gimp::CodeGen::pdb;
init_value => 'NULL',
in_annotate => '(element-type gdouble)',
out_annotate => '(element-type gdouble) (transfer full)',
get_value_func => '$var = gimp_value_get_float_array ($value, (gsize *) &$var_len)',
dup_value_func => '$var = GIMP_VALUES_DUP_FLOAT_ARRAY ($value, (gsize *) $var_len)',
get_value_func => '$var = gimp_value_get_float_array ($value, &$var_len)',
dup_value_func => '$var = GIMP_VALUES_DUP_FLOAT_ARRAY ($value, $var_len)',
set_value_func => 'gimp_value_set_float_array ($value, $var, $var_len)',
take_value_func => 'gimp_value_take_float_array ($value, $var, $var_len)' },