Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2020-04-08 23:36:58 +0300
committerJulian Eisel <julian@blender.org>2020-04-09 00:22:33 +0300
commit74fa8787d8640c0856f3192898b8ebeaa0d639ac (patch)
tree0721bc4708bc5886d9dce9365d87d4da4ed1eea4
parentc13aa95eda888c61514693c33ec506bf182257a1 (diff)
Fix error in UI_butstore_ API
If the `uiButStore` data was freed after the buttons/blocks were updated from previous instances (see `UI_block_update_from_old()`), e.g. by delaying that to the "afterfuncs" (`ui_apply_but_funcs_after()`), the data would get lost. As result, the button pointers that the API is supposed to keep valid would point to freed memory. This wasn't an issue so far since the API didn't happen to be used this way. That changes with the next commit.
-rw-r--r--source/blender/editors/interface/interface_utils.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index a69837e9b51..67cb91a3cc4 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -647,6 +647,7 @@ void UI_butstore_free(uiBlock *block, uiButStore *bs_handle)
}
BLI_freelistN(&bs_handle->items);
+ BLI_assert(BLI_findindex(&block->butstore, bs_handle) != -1);
BLI_remlink(&block->butstore, bs_handle);
MEM_freeN(bs_handle);
@@ -747,8 +748,7 @@ void UI_butstore_update(uiBlock *block)
/* move this list to the new block */
if (block->oldblock) {
if (block->oldblock->butstore.first) {
- block->butstore = block->oldblock->butstore;
- BLI_listbase_clear(&block->oldblock->butstore);
+ BLI_movelisttolist(&block->butstore, &block->oldblock->butstore);
}
}