summaryrefslogtreecommitdiff
path: root/pbx
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2015-04-06 18:03:54 +0000
committerMatthew Jordan <mjordan@digium.com>2015-04-06 18:03:54 +0000
commite309a91e2de399f4b1e34fb0b031cc3b78975354 (patch)
tree0f20286e84a35fd70f173333e5615a1f7da18971 /pbx
parented3cf8761bcbc088d00a86b46f066ead14c4bddc (diff)
clang compiler warnings: Fix sometimes-uninitialized warning in pbx_config
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) ........ Merged revisions 434090 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 434091 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434092 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'pbx')
-rw-r--r--pbx/pbx_config.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c
index a42ea47fd..70d4dc3ce 100644
--- a/pbx/pbx_config.c
+++ b/pbx/pbx_config.c
@@ -956,7 +956,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 = "/";
@@ -970,12 +972,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",