Check for NULL frame, before dereferencing pointer.
authorTilghman Lesher <tilghman@meg.abyt.es>
Sun, 9 Aug 2009 07:11:22 +0000 (07:11 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Sun, 9 Aug 2009 07:11:22 +0000 (07:11 +0000)
(closes issue #15617)
 Reported by: rain

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

apps/app_stack.c

index 1a25231..d46f048 100644 (file)
@@ -474,7 +474,12 @@ static int local_read(struct ast_channel *chan, const char *cmd, char *data, cha
 
        oldlist = stack_store->data;
        AST_LIST_LOCK(oldlist);
-       frame = AST_LIST_FIRST(oldlist);
+       if (!(frame = AST_LIST_FIRST(oldlist))) {
+               /* Not within a Gosub routine */
+               AST_LIST_UNLOCK(oldlist);
+               return -1;
+       }
+
        AST_LIST_TRAVERSE(&frame->varshead, variables, entries) {
                if (!strcmp(data, ast_var_name(variables))) {
                        const char *tmp;