script-fu: fix out-of-bounds array access

I noticed this in coverity. I couldn't find any actual script using
SF_DISPLAY, so the impact probably isn't very big.
Because the enums start at 0, the size of the array should be at least
one more than the value of the last enum, which was not the case here.

Increase the size of the array by 1, so that accessing SF_DISPLAY,
which is the enum with the highest value, is valid.
This commit is contained in:
Jacob Boerema 2023-07-11 12:04:24 -04:00
parent 624ae512fc
commit 6484193d8f
1 changed files with 2 additions and 2 deletions

View File

@ -731,12 +731,12 @@ script_fu_arg_append_repr_from_self (SFArg *arg,
/* Array the size of the enum
* Counts names generated per SF type per generator session.
*/
static gint arg_count[SF_DISPLAY] = { 0, };
static gint arg_count[SF_DISPLAY + 1] = { 0, };
void
script_fu_arg_reset_name_generator (void)
{
for (guint i = 0; i<SF_DISPLAY; i++)
for (guint i = 0; i <= SF_DISPLAY; i++)
arg_count[i] = 0;
}