Fix outliner library override data storage (undefined behavior)

The Library Overrides view of the Outliner was casting a
`TreeElementOverridesData` pointer to an `ID` pointer, which would be
undefined behavior. Make sure it uses the actual ID referenced by the
`TreeElementOverridesData`.
This commit is contained in:
Julian Eisel
2023-08-01 18:54:32 +02:00
parent c6118da243
commit 49adf49bae
2 changed files with 7 additions and 3 deletions

View File

@@ -32,6 +32,7 @@
#include "tree/common.hh"
#include "tree/tree_display.hh"
#include "tree/tree_element.hh"
#include "tree/tree_element_overrides.hh"
#ifdef WIN32
# include "BLI_math_base.h" /* M_PI */
@@ -239,6 +240,9 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
else if (ELEM(type, TSE_GENERIC_LABEL)) {
id = nullptr;
}
else if (ELEM(type, TSE_LIBRARY_OVERRIDE, TSE_LIBRARY_OVERRIDE_OPERATION)) {
id = &static_cast<TreeElementOverridesData *>(idv)->id;
}
else if (type == TSE_BONE) {
id = static_cast<BoneElementCreateData *>(idv)->armature_id;
}

View File

@@ -114,9 +114,9 @@ typedef enum eTreeStoreElemType {
TSE_GPENCIL_EFFECT_BASE = 42,
TSE_GPENCIL_EFFECT = 43,
TSE_LIBRARY_OVERRIDE_BASE = 44,
TSE_LIBRARY_OVERRIDE = 45, /* No ID */
TSE_LIBRARY_OVERRIDE_OPERATION = 46, /* No ID */
TSE_GENERIC_LABEL = 47, /* No ID */
TSE_LIBRARY_OVERRIDE = 45,
TSE_LIBRARY_OVERRIDE_OPERATION = 46,
TSE_GENERIC_LABEL = 47, /* No ID */
} eTreeStoreElemType;
/** Check whether given #TreeStoreElem should have a real ID in #TreeStoreElem.id member. */