diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-10-19 14:58:01 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-10-19 14:58:01 +0300 |
commit | 0f8a57de68f706f73c25c8c456113f25ed634662 (patch) | |
tree | 834d9b1e1049d3118c57dfe3eb88fd369b814d0f /source/blender/blenkernel/intern/library.c | |
parent | 335e454db65571e16756d7b287e81bc4dea6b7e6 (diff) | |
parent | 1cddab18ded9489f2f29b0655698f2e2e4e2076a (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index f929672e830..667352b6ddb 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -538,13 +538,23 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag, con ID_IP /* Deprecated */ BLI_assert(test || (r_newid != NULL)); - if (r_newid != NULL && (flag & LIB_ID_CREATE_NO_ALLOCATE) == 0) { - *r_newid = NULL; - } + /* Early output is source is NULL. */ if (id == NULL) { return false; } - + /* Make sure destination pointer is all good. */ + if ((flag & LIB_ID_CREATE_NO_ALLOCATE) == 0) { + if (r_newid != NULL) { + *r_newid = NULL; + } + } + else { + if (r_newid != NULL && *r_newid != NULL) { + /* Allow some garbage non-initialized memory to go in. */ + const size_t size = BKE_libblock_get_alloc_info(GS(id->name), NULL); + memset(*r_newid, 0, size); + } + } if (ELEM(GS(id->name), LIB_ID_TYPES_NOCOPY)) { return false; } |