]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix a crash resulting from a datastore with inheritance but no duplicate callback
authorMark Michelson <mmichelson@digium.com>
Tue, 23 Dec 2008 15:16:26 +0000 (15:16 +0000)
committerMark Michelson <mmichelson@digium.com>
Tue, 23 Dec 2008 15:16:26 +0000 (15:16 +0000)
The fix for this is to simply set the newly created datastore's data pointer
to NULL if it is inherited but has no duplicate callback.

(closes issue #14113)
Reported by: francesco_r
Patches:
      14113.patch uploaded by putnopvut (license 60)
Tested by: francesco_r

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

main/channel.c

index 48ad052868261686828965710681fe9d75fa811a..6d6e5157e58a40c0261f43ce40ba444a5901492a 100644 (file)
@@ -1359,7 +1359,7 @@ int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *
                if (datastore->inheritance > 0) {
                        datastore2 = ast_channel_datastore_alloc(datastore->info, datastore->uid);
                        if (datastore2) {
-                               datastore2->data = datastore->info->duplicate(datastore->data);
+                               datastore2->data = datastore->info->duplicate ? datastore->info->duplicate(datastore->data) : NULL;
                                datastore2->inheritance = datastore->inheritance == DATASTORE_INHERIT_FOREVER ? DATASTORE_INHERIT_FOREVER : datastore->inheritance - 1;
                                AST_LIST_INSERT_TAIL(&to->datastores, datastore2, entry);
                        }