aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/vector.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-12-31 23:19:41 -0800
committerChris Robinson <[email protected]>2017-12-31 23:19:41 -0800
commit6dd1643a701c45fa779ea6da180f120c36c31a97 (patch)
treec2281617aa0ebf9fec4c67f351bbaa3c88ae10a4 /Alc/vector.h
parent48916ebd76811086c877e64820aaa7af4735272a (diff)
Avoid dereferencing a NULL pointer
Even though it's taking the address of a member, it's still technically a derefernce and thus undefined behavior. sizeof doesn't "execute" the expression, so derefering in it instead is fine.
Diffstat (limited to 'Alc/vector.h')
-rw-r--r--Alc/vector.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/Alc/vector.h b/Alc/vector.h
index ed0780e3..ed9acfb0 100644
--- a/Alc/vector.h
+++ b/Alc/vector.h
@@ -37,7 +37,8 @@ typedef const _##N* const_##N;
\
if(((_x) ? (_x)->Capacity : 0) < _cap) \
{ \
- ptrdiff_t data_offset = (char*)((_x)->Data) - (char*)(_x); \
+ ptrdiff_t data_offset = (_x) ? (char*)((_x)->Data) - (char*)(_x) : \
+ sizeof(*(_x)); \
size_t old_size = ((_x) ? (_x)->Size : 0); \
void *temp; \
\