commit bdf42537c5792f6beb0360517ff378834cfd8a68
parent 5fc87aedad86a8410a360ba718096e613ddf11f6
Author: robert <robertrussell.72001@gmail.com>
Date: Sat, 30 Jul 2022 14:29:05 -0700
Add reallocarray implementation
reallocarray is nonstandard and glibc declares it only when _GNU_SOURCE
is defined. Without this patch or _GNU_SOURCE (for glibc < 2.29) defined,
you get a segfault from reallocarray being implicitly declared with the
wrong signature.
Signed-off-by: Laslo Hunhold <dev@frign.de>
Diffstat:
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/gen/util.c b/gen/util.c
@@ -31,6 +31,16 @@ struct break_test_payload
size_t *testlen;
};
+static void *
+reallocarray(void *p, size_t len, size_t size)
+{
+ if (len > 0 && size > SIZE_MAX/len) {
+ errno = ENOMEM;
+ return NULL;
+ }
+ return realloc(p, len*size);
+}
+
int
hextocp(const char *str, size_t len, uint_least32_t *cp)
{