]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
clang compiler warnings: Fix sometimes-uninitialized warning in pbx_config
authorMatthew Jordan <mjordan@digium.com>
Mon, 6 Apr 2015 18:03:23 +0000 (18:03 +0000)
committerMatthew Jordan <mjordan@digium.com>
Mon, 6 Apr 2015 18:03:23 +0000 (18:03 +0000)
This patch fixes a warning caught by clang, in which a char pointer could be
assigned to before it was initialized. The patch re-organizes the code to
ensure that the pointer is always initialized, even on off nominal paths.

Review: https://reviewboard.asterisk.org/r/4529

ASTERISK-24917
Reported by: dkdegroot
patches:
  rb4529.patch submitted by dkdegroot (License 6600)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@434090 65c4cc65-6c06-0410-ace0-fbb531ad65f3

pbx/pbx_config.c

index 1fb562e3c9dd0839c6d3178b5a1301dc290197f2..7114bbc1e90856b51865619895482e67219c612b 100644 (file)
@@ -855,7 +855,9 @@ static char *handle_cli_dialplan_save(struct ast_cli_entry *e, int cmd, struct a
                                        const char *el = ast_get_extension_label(p);
                                        char label[128] = "";
                                        char *appdata = ast_get_extension_app_data(p);
-                                       char *escaped;
+
+                                       int escaped_len = (!ast_strlen_zero(appdata)) ? 2 * strlen(appdata) + 1 : 1;
+                                       char escaped[escaped_len];
 
                                        if (ast_get_extension_matchcid(p)) {
                                                sep = "/";
@@ -869,12 +871,9 @@ static char *handle_cli_dialplan_save(struct ast_cli_entry *e, int cmd, struct a
                                        }
 
                                        if (!ast_strlen_zero(appdata)) {
-                                               int escaped_len = 2 * strlen(appdata) + 1;
-                                               char escaped[escaped_len];
-
                                                ast_escape_semicolons(appdata, escaped, escaped_len);
                                        } else {
-                                               escaped = "";
+                                               escaped[0] = '\0';
                                        }
 
                                        fprintf(output, "exten => %s%s%s,%d%s,%s(%s)\n",