]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Allow func_curl to exit gracefully if list allocation fails during write
authorMatthew Jordan <mjordan@digium.com>
Mon, 9 Apr 2012 21:44:03 +0000 (21:44 +0000)
committerMatthew Jordan <mjordan@digium.com>
Mon, 9 Apr 2012 21:44:03 +0000 (21:44 +0000)
If the global_curl_info data structure could not be allocated, the
datastore associated with the operation would be free'd, but the function
would not return.  This would later dereference the datastore, almost
certainly causing Asterisk to crash.  With this patch, if the data
structure is not allocated the method will return an error code, and
not attempt any further operation.

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

funcs/func_curl.c

index 294ea2621dbba107e63817393c49dd370fd12d07..1bcf2336165f7f395eea7965bde0e0af8db6f41e 100644 (file)
@@ -287,6 +287,7 @@ static int acf_curlopt_write(struct ast_channel *chan, const char *cmd, char *na
                        if (!(list = ast_calloc(1, sizeof(*list)))) {
                                ast_log(LOG_ERROR, "Unable to allocate list head.  Cannot set any CURL options\n");
                                ast_datastore_free(store);
+                               return -1;
                        }
 
                        store->data = list;