We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4102c27 commit 1bdd07eCopy full SHA for 1bdd07e
main/reallocarray.c
@@ -22,13 +22,14 @@
22
23
PHPAPI void* php_reallocarray(void *p, size_t nmb, size_t siz)
24
{
25
-#ifndef _WIN32
26
size_t r;
+#ifndef _WIN32
27
if (__builtin_mul_overflow(nmb, siz, &r)) {
28
#else
29
- // nmb an siz must be lower than sqrt SIZE_MAX+1
30
- static size_t elim = 1UL << (sizeof(size_t) * CHAR_BIT / 2);
31
- if ((nmb >= elim || siz >= elim) && nmb > 0 && SIZE_MAX / nmb < siz) {
+
+ // nmb and siz must be lower than sqrt SIZE_MAX+1
+ r = siz * nmb;
32
+ if (siz != 0 && r / siz != nmb) {
33
#endif
34
// EOVERFLOW may have been, arguably, more appropriate
35
// but this is what other implementations set
0 commit comments