From 4b5afca76cd7f29776c849f4138eca216bf2df64 Mon Sep 17 00:00:00 2001 From: derselbst Date: Thu, 28 Jan 2021 10:34:39 +0100 Subject: [PATCH] Fix a double-free when issuing the info command on string setting Fixes #756. --- src/bindings/fluid_cmd.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/bindings/fluid_cmd.c b/src/bindings/fluid_cmd.c index 847ec7f0..21b41cc9 100644 --- a/src/bindings/fluid_cmd.c +++ b/src/bindings/fluid_cmd.c @@ -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; } @@ -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; } @@ -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: ");