[master] 5498b039c miniobj: A flex array may start in struct padding
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Fri Aug 18 06:24:08 UTC 2023
commit 5498b039c3dfc25b8ca8ddc14c1f1822aff6cd4e
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Thu Aug 17 10:22:03 2023 +0200
miniobj: A flex array may start in struct padding
We lose the ability to check that fld is indeed the last field, but we
never had that ability to begin with.
diff --git a/include/miniobj.h b/include/miniobj.h
index 832998019..7551cab53 100644
--- a/include/miniobj.h
+++ b/include/miniobj.h
@@ -32,11 +32,8 @@
#define ALLOC_FLEX_OBJ(to, fld, len, type_magic) \
do { \
- v_static_assert( \
- sizeof *(to) == offsetof(typeof(*(to)), fld), \
- "the last field must be a flexible array"); \
- (to) = calloc(1, \
- sizeof *(to) + ((len) * sizeof *((to)->fld))); \
+ (to) = calloc(1, offsetof(typeof(*(to)), fld) + \
+ ((len) * sizeof *((to)->fld))); \
if ((to) != NULL) \
(to)->magic = (type_magic); \
} while (0)
More information about the varnish-commit
mailing list