From da13a3bdeea5313dcb63fca259c0fb8ed4d7ae22 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Jan 2019 23:49:21 +1100 Subject: Fix texture paint accessing freed memory Part of T60660 --- source/blender/blenkernel/intern/undo_system.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source') diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c index fa3abfd33f0..12cd8fc43e9 100644 --- a/source/blender/blenkernel/intern/undo_system.c +++ b/source/blender/blenkernel/intern/undo_system.c @@ -764,6 +764,10 @@ void BKE_undosys_type_free_all(void) * Unfortunately we need this for a handful of places. */ +/* Disable for now since it accesses freed memory. + * The pointer can only be a key, we can't read it's contents. */ +#define USE_LIB_SKIP + static void UNUSED_FUNCTION(BKE_undosys_foreach_ID_ref( UndoStack *ustack, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data)) { @@ -870,9 +874,11 @@ void BKE_undosys_ID_map_destroy(UndoIDPtrMap *idpmap) void BKE_undosys_ID_map_add(UndoIDPtrMap *map, ID *id) { uint index; +#ifdef USE_LIB_SKIP if (id->lib != NULL) { return; } +#endif if (undosys_ID_map_lookup_index(map, id, &index)) { return; /* exists. */ @@ -932,7 +938,11 @@ ID *BKE_undosys_ID_map_lookup_with_prev(const UndoIDPtrMap *map, ID *id_src, ID return id_prev_match[1]; } else { +#ifdef USE_LIB_SKIP + ID *id_dst = BKE_undosys_ID_map_lookup(map, id_src); +#else ID *id_dst = (id_src->lib == NULL) ? BKE_undosys_ID_map_lookup(map, id_src) : id_src; +#endif id_prev_match[0] = id_src; id_prev_match[1] = id_dst; return id_dst; -- cgit v1.2.3