Skip to content

Commit

Permalink
Fix a double-free when issuing the info command on string setting
Browse files Browse the repository at this point in the history
Fixes #756.
  • Loading branch information
derselbst committed Jan 28, 2021
1 parent fff5182 commit 4b5afca
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions src/bindings/fluid_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1914,14 +1914,10 @@ fluid_handle_get(void *data, int ac, char **av, fluid_ostream_t out)

case FLUID_STR_TYPE:
{
char *s;
char *s = NULL;
fluid_settings_dupstr(handler->synth->settings, av[0], &s); /* ++ alloc string */
fluid_ostream_printf(out, "%s\n", s ? s : "NULL");

if(s)
{
FLUID_FREE(s); /* -- free string */
}
FLUID_FREE(s); /* -- free string */

break;
}
Expand Down Expand Up @@ -1999,14 +1995,10 @@ static void fluid_handle_settings_iter2(void *data, const char *name, int type)

case FLUID_STR_TYPE:
{
char *s;
char *s = NULL;
fluid_settings_dupstr(d->synth->settings, name, &s); /* ++ alloc string */
fluid_ostream_printf(d->out, "%s\n", s ? s : "NULL");

if(s)
{
FLUID_FREE(s); /* -- free string */
}
FLUID_FREE(s); /* -- free string */

break;
}
Expand Down Expand Up @@ -2133,19 +2125,16 @@ fluid_handle_info(void *d, int ac, char **av, fluid_ostream_t out)

case FLUID_STR_TYPE:
{
char *s;
char *s = NULL;
fluid_settings_dupstr(settings, av[0], &s); /* ++ alloc string */
fluid_ostream_printf(out, "%s:\n", av[0]);
fluid_ostream_printf(out, "Type: string\n");
fluid_ostream_printf(out, "Value: %s\n", s ? s : "NULL");
FLUID_FREE(s); /* -- free string */

fluid_settings_getstr_default(settings, av[0], &s);
fluid_ostream_printf(out, "Default value: %s\n", s);

if(s)
{
FLUID_FREE(s);
}

data.out = out;
data.first = 1;
fluid_ostream_printf(out, "Options: ");
Expand Down

0 comments on commit 4b5afca

Please sign in to comment.