]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
main/cli: Use proper string methods to check existence of context/exten/app 73/1673/1
authorMatt Jordan <mjordan@digium.com>
Thu, 22 Oct 2015 14:44:43 +0000 (09:44 -0500)
committerMatt Jordan <mjordan@digium.com>
Sat, 21 Nov 2015 04:02:45 +0000 (22:02 -0600)
Because the context, extension, and application are stored in stringfields,
checking for them being NULL doesn't work so well. This patch uses the
appropriate string library call, ast_strlen_zero, to see if there is a value
in the context/exten/app values.

Change-Id: Ie09623bfdf35f5a8d3b23dd596647fe3c97b9a23

main/cli.c

index 0d66f3e48e433082a5d7c4245becd070fca1c775..7f86eab3a5bd0fb8478d60d85d42ee96354d3970 100644 (file)
@@ -1076,10 +1076,12 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
                                char locbuf[40] = "(None)";
                                char appdata[40] = "(None)";
 
-                               if (!cs->context && !cs->exten)
+                               if (!ast_strlen_zero(cs->context) && !ast_strlen_zero(cs->exten)) {
                                        snprintf(locbuf, sizeof(locbuf), "%s@%s:%d", cs->exten, cs->context, cs->priority);
-                               if (cs->appl)
+                               }
+                               if (!ast_strlen_zero(cs->appl)) {
                                        snprintf(appdata, sizeof(appdata), "%s(%s)", cs->appl, S_OR(cs->data, ""));
+                               }
                                ast_cli(a->fd, FORMAT_STRING, cs->name, locbuf, ast_state2str(cs->state), appdata);
                        }
                }