klib
klib copied to clipboard
Introduce kreallocarray with overflow checking
Introduce a kreallocarray with overflow checking, with a signature
equivalent to OpenBSD reallocarray(3). This prevents a realloc
from appearing to succeed when new_n_buckets is larger than
SIZE_MAX / sizeof(khkey_t) or SIZE_MAX / sizeof(khval_t).
I think that - should be a /
-#define kreallocarray(P,N,Z) ((SIZE_MAX - N < Z) ? NULL : krealloc(P, (N*Z)))
+#define kreallocarray(P,N,Z) ((SIZE_MAX / N < Z) ? NULL : krealloc(P, (N*Z)))
Thanks @noporpoise - that - should indeed be a /. Fixed!