]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
avoid segfault caused by user error
authorDavid Vossel <dvossel@digium.com>
Thu, 16 Jul 2009 21:24:16 +0000 (21:24 +0000)
committerDavid Vossel <dvossel@digium.com>
Thu, 16 Jul 2009 21:24:16 +0000 (21:24 +0000)
If the CALLERPRES() dialplan function is set to nothing,
a segfault occurs.  This is user error to begin with, but
I'd rather see a cli warning message than have Asterisk
crash on me.

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

main/callerid.c

index cd6cde116c80509528dadaf060f3c89e9fea7076..edc00a5e5793f57a10e560cbd07618736f8c8dfd 100644 (file)
@@ -1092,6 +1092,10 @@ int ast_parse_caller_presentation(const char *data)
 {
        int i;
 
+       if (!data) {
+               return -1;
+       }
+
        for (i = 0; i < ((sizeof(pres_types) / sizeof(pres_types[0]))); i++) {
                if (!strcasecmp(pres_types[i].name, data))
                        return pres_types[i].val;