]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Don't return a partially initialized datastore.
authorRussell Bryant <russell@russellbryant.com>
Thu, 1 Jul 2010 22:09:19 +0000 (22:09 +0000)
committerRussell Bryant <russell@russellbryant.com>
Thu, 1 Jul 2010 22:09:19 +0000 (22:09 +0000)
If memory allocation fails in ast_strdup(), don't return a partially
initialized datastore.  Bad things may happen.

(related to ABE-2415)

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

main/channel.c

index 70324d9e503a3b3fb7bca060798db15b86905ecb..b10c07cfe050832a786fc508362e9ee308c75935 100644 (file)
@@ -1439,7 +1439,10 @@ struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_inf
 
        datastore->info = info;
 
-       datastore->uid = ast_strdup(uid);
+       if (!ast_strlen_zero(uid) && !(datastore->uid = ast_strdup(uid))) {
+               ast_free(datastore);
+               datastore = NULL;
+       }
 
        return datastore;
 }