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:
authorAnkit Meel <ankitm>2020-09-29 22:31:58 +0300
committerAnkit Meel <ankitjmeel@gmail.com>2020-09-29 22:46:02 +0300
commitc1cdde04e270598d4a3973d85ac98d30cc86937e (patch)
treea126c0c35d4fb1c2b3ec9036077c8582b33cd20b /intern/cycles/graph/node_type.h
parent4c3047a9cdff686411077b1ccd5709eb221bf41a (diff)
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
Diffstat (limited to 'intern/cycles/graph/node_type.h')
-rw-r--r--intern/cycles/graph/node_type.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/intern/cycles/graph/node_type.h b/intern/cycles/graph/node_type.h
index 0d182945e16..69891e6a10a 100644
--- a/intern/cycles/graph/node_type.h
+++ b/intern/cycles/graph/node_type.h
@@ -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, \