[PATCH 2/3] include: Define CONTAINING_RECORD using FIELD_OFFSET
Amine Khaldi
amine.khaldi at reactos.org
Mon Dec 10 12:42:28 CST 2012
This prevents the undefined behavior (null pointer dereference)
diagnostics (clang with ubsan checks for example).
---
include/winnt.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/winnt.h b/include/winnt.h
index a3b996a..3765705 100644
--- a/include/winnt.h
+++ b/include/winnt.h
@@ -754,7 +754,7 @@ typedef struct _MEMORY_BASIC_INFORMATION
#endif
#define CONTAINING_RECORD(address, type, field) \
- ((type *)((PCHAR)(address) - (PCHAR)(&((type *)0)->field)))
+ ((type *)((PCHAR)(address) - FIELD_OFFSET(type, field)))
/* Types */
--
1.8.0
More information about the wine-patches
mailing list