diff options
author | Ankit Meel <ankitm> | 2020-10-01 07:47:13 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-10-01 07:49:44 +0300 |
commit | 99fb853734cba8b778f9e60789ef51bd638d35da (patch) | |
tree | f5d0ce6eee3abb634c687f84942479cec70a7211 /intern/guardedalloc | |
parent | c1ae12bf5e3dd77e1b814869dcb5766a0a51d594 (diff) |
Cleanup: avoid member access within null pointer
While harmless, UBSan warns about this.
Prefer offsetof where possible since it's more readable.
Diffstat (limited to 'intern/guardedalloc')
-rw-r--r-- | intern/guardedalloc/intern/mallocn_guarded_impl.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.c b/intern/guardedalloc/intern/mallocn_guarded_impl.c index 6c08cb3bb62..6a0d104d47d 100644 --- a/intern/guardedalloc/intern/mallocn_guarded_impl.c +++ b/intern/guardedalloc/intern/mallocn_guarded_impl.c @@ -24,6 +24,7 @@ */ #include <stdarg.h> +#include <stddef.h> /* offsetof */ #include <stdlib.h> #include <string.h> /* memcpy */ #include <sys/types.h> @@ -153,7 +154,7 @@ static const char *check_memlist(MemHead *memh); #define MEMTAG3 MAKE_ID('O', 'C', 'K', '!') #define MEMFREE MAKE_ID('F', 'R', 'E', 'E') -#define MEMNEXT(x) ((MemHead *)(((char *)x) - ((char *)&(((MemHead *)0)->next)))) +#define MEMNEXT(x) ((MemHead *)(((char *)x) - offsetof(MemHead, next))) /* --------------------------------------------------------------------- */ /* vars */ |