[Bf-blender-cvs] [09b9e1e95ee] blender-v3.4-release: Fix T102225: Crash opening menus
Sergey Sharybin
noreply at git.blender.org
Thu Nov 3 14:32:18 CET 2022
Commit: 09b9e1e95ee4a5cea5297d06af26385b73856aeb
Author: Sergey Sharybin
Date: Thu Nov 3 10:42:48 2022 +0100
Branches: blender-v3.4-release
https://developer.blender.org/rB09b9e1e95ee4a5cea5297d06af26385b73856aeb
Fix T102225: Crash opening menus
Seems to be introduced by 99e5024e97f.
The crash is caused by the difference in the expected alignment
of the `uiPopupMenu` which is 16 bytes and the actual alignment
returned by the `MEM_mallocN()` which is 8 bytes due to the memory
head.
Now made it so that `MEM_new()` can be used for types with any
alignment.
Differential Revision: https://developer.blender.org/D16375
===================================================================
M intern/guardedalloc/MEM_guardedalloc.h
===================================================================
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index fdd77fb9eef..5ae33343949 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -271,7 +271,7 @@ void MEM_use_guarded_allocator(void);
template<typename T, typename... Args>
inline T *MEM_new(const char *allocation_name, Args &&...args)
{
- void *buffer = MEM_mallocN(sizeof(T), allocation_name);
+ void *buffer = MEM_mallocN_aligned(sizeof(T), alignof(T), allocation_name);
return new (buffer) T(std::forward<Args>(args)...);
}
More information about the Bf-blender-cvs
mailing list