]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[Core] Fix a false-positive memory leak detected by scan-build in switch_channel_set_...
authorAndrey Volk <andywolk@gmail.com>
Mon, 5 Apr 2021 20:23:37 +0000 (23:23 +0300)
committerAndrey Volk <andywolk@gmail.com>
Tue, 19 Oct 2021 17:45:08 +0000 (20:45 +0300)
src/switch_channel.c

index 9ce2fdc52ef955d41396dba22548f1bc1ea2c163..8aa36aec888044cc4b260a2f71b19ce31109cd24 100644 (file)
@@ -1511,11 +1511,12 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_strip_quotes_var_che
                        int ok = 1;
                        char *t = (char *)value;
                        char *r = (char *)value;
+                       char *tmp = NULL;
 
                        if (t && *t == '"') {
                                t++;
                                if (end_of(t) == '"') {
-                                       r = strdup(t);
+                                       r = tmp = strdup(t);
                                        switch_assert(r);
                                        end_of(r) = '\0';
                                }
@@ -1530,7 +1531,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_strip_quotes_var_che
                                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, "Invalid data (${%s} contains a variable)\n", varname);
                        }
 
-                       if (r != value) free(r);
+                       switch_safe_free(tmp);
                }
                status = SWITCH_STATUS_SUCCESS;
        }