patch 8.1.1827: allocating more memory than needed for extended structs
Problem: Allocating more memory than needed for extended structs.
Solution: Use offsetof() instead of sizeof(). (Dominique Pelle,
closes #4786)
diff --git a/src/regexp.c b/src/regexp.c
index c95795d..dd99607 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -1319,7 +1319,7 @@
return NULL;
/* Allocate space. */
- r = alloc(sizeof(bt_regprog_T) + regsize);
+ r = alloc(offsetof(bt_regprog_T, program) + regsize);
if (r == NULL)
return NULL;
r->re_in_use = FALSE;