]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Get rid of an annoying "Possible programming error" message.
authorMark Michelson <mmichelson@digium.com>
Tue, 20 Mar 2012 19:30:07 +0000 (19:30 +0000)
committerMark Michelson <mmichelson@digium.com>
Tue, 20 Mar 2012 19:30:07 +0000 (19:30 +0000)
If an extension's 'app' field is NULL, then a "(null)" string
would be written into an ast_str due to the way that snprintf
works. When this is passed to ast_strlen_zero(), it fires up
a big warning indicating something is probably wrong.

There indeed was a problem, but luckily it wasn't a very big
problem. After the failed ast_strlen_zero() check and big
warning message, the very next if statement, checking to
see if the "(null)" matched a presence provider, would fail,
so no harm was done.

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

main/pbx.c

index 4457dead7db2df2519a4d6c9644a5e520d94b54c..5f6c37b07e7fdd92e9cbd4467b0e67dddc1cf03e 100644 (file)
@@ -4546,6 +4546,7 @@ static int handle_presencechange(void *datap)
        i = ao2_iterator_init(hints, 0);
        for (; (hint = ao2_iterator_next(&i)); ao2_ref(hint, -1)) {
                struct ast_state_cb *state_cb;
+               const char *app;
                char *parse;
 
                ao2_lock(hint);
@@ -4557,14 +4558,14 @@ static int handle_presencechange(void *datap)
                }
 
                /* Does this hint monitor the device that changed state? */
-               ast_str_set(&hint_app, 0, "%s", ast_get_extension_app(hint->exten));
-               parse = parse_hint_presence(hint_app);
-               if (ast_strlen_zero(parse)) {
+               app = ast_get_extension_app(hint->exten);
+               if (ast_strlen_zero(app)) {
                        /* The hint does not monitor presence at all. */
                        ao2_unlock(hint);
                        continue;
                }
-
+               ast_str_set(&hint_app, 0, "%s", app);
+               parse = parse_hint_presence(hint_app);
                if (strcasecmp(parse, pc->provider)) {
                        /* The hint does not monitor the presence provider. */
                        ao2_unlock(hint);