Fix T81100: ccl::Node: ASan SEGV due to bad pointer
`SOCKET_OFFSETOF` was added in the initial commit {rBec51175f1fd6c91d5} when `offsetof` [1] was not supported well enough. GCC and LLVM support it since C++17. Other two changes: type and size check can be done without creating an invalid address too. [1] https://cppreference.com/w/cpp/types/offsetof Reviewed By: campbellbarton, brecht Maniphest Tasks: T81100 Differential Revision: https://developer.blender.org/D9042
This commit is contained in:
parent
4c3047a9cd
commit
c1cdde04e2
Notes:
blender-bot
2023-02-14 11:35:46 +01:00
Referenced by issue #81100, Crash on launch: AddressSanitizer: SEGV on unknown address
|
@ -165,12 +165,12 @@ struct NodeType {
|
|||
|
||||
/* Sock Definition Macros */
|
||||
|
||||
#define SOCKET_OFFSETOF(T, name) (((char *)&(((T *)1)->name)) - (char *)1)
|
||||
#define SOCKET_SIZEOF(T, name) (sizeof(((T *)1)->name))
|
||||
#define SOCKET_OFFSETOF(T, name) offsetof(T, name)
|
||||
#define SOCKET_SIZEOF(T, name) (sizeof(T::name))
|
||||
#define SOCKET_DEFINE(name, ui_name, default_value, datatype, TYPE, flags, ...) \
|
||||
{ \
|
||||
static datatype defval = default_value; \
|
||||
CHECK_TYPE(((T *)1)->name, datatype); \
|
||||
CHECK_TYPE(T::name, datatype); \
|
||||
type->register_input(ustring(#name), \
|
||||
ustring(ui_name), \
|
||||
TYPE, \
|
||||
|
|
Loading…
Reference in New Issue