* tests/test-reallocarray.c (main): Don’t assume that
PTRDIFF_MAX / 2 + 1 <= SIZE_MAX. POSIX allows platforms
where this isn’t true, though I don’t know of any examples.
2021-05-30 Paul Eggert <eggert@cs.ucla.edu>
+ reallocarray-tests: port to weird platforms
+ * tests/test-reallocarray.c (main): Don’t assume that
+ PTRDIFF_MAX / 2 + 1 <= SIZE_MAX. POSIX allows platforms
+ where this isn’t true, though I don’t know of any examples.
+
dfa, etc.: prefer xreallocarray to older name
* lib/dfa.c (addtok_mb, realloc_trans_if_necessary, enlist):
* lib/readtokens.c (readtokens):
{
void *volatile p = NULL;
- p = reallocarray (p, PTRDIFF_MAX / n + 1, n);
- ASSERT (p == NULL);
- ASSERT (errno == ENOMEM);
+ if (PTRDIFF_MAX / n + 1 <= SIZE_MAX)
+ {
+ p = reallocarray (p, PTRDIFF_MAX / n + 1, n);
+ ASSERT (p == NULL);
+ ASSERT (errno == ENOMEM);
+ }
p = reallocarray (p, SIZE_MAX / n + 1, n);
ASSERT (p == NULL);