- Fixed bug #46347 (parse_ini_file() doesn't support * in keys). (Nuno)
- Fixed bug #46048 (SimpleXML top-level @attributes not part of iterator).
(David C.)
+- Fixed bug #45877 (Array key '2147483647' left as string). (Matt)
- Fixed bug #45432 (PDO: persistent connection leak). (Felipe)
- Fixed bug #43831 ($this gets mangled when extending PDO with persistent
connection). (Felipe)
--- /dev/null
+--TEST--
+Bug #45877 (Array key '2147483647' left as string)
+--FILE--
+<?php
+$keys = array(PHP_INT_MAX,
+ (string) PHP_INT_MAX,
+ (string) (-PHP_INT_MAX - 1),
+ -PHP_INT_MAX - 1,
+ (string) (PHP_INT_MAX + 1));
+
+var_dump(array_fill_keys($keys, 1));
+?>
+--EXPECTF--
+array(3) {
+ [%d7]=>
+ int(1)
+ [-%d8]=>
+ int(1)
+ ["%d8"]=>
+ int(1)
+}
#define LONG_MIN (- LONG_MAX - 1)
#endif
+#if SIZEOF_LONG == 4
+#define MAX_LENGTH_OF_LONG 11
+static const char long_min_digits[] = "2147483648";
+#elif SIZEOF_LONG == 8
+#define MAX_LENGTH_OF_LONG 20
+static const char long_min_digits[] = "9223372036854775808";
+#else
+#error "Unknown SIZEOF_LONG"
+#endif
+
+#define MAX_LENGTH_OF_DOUBLE 32
+
#undef SUCCESS
#undef FAILURE
#define SUCCESS 0
} \
if ((*tmp>='0' && *tmp<='9')) do { /* possibly a numeric index */ \
const char *end=key+length-1; \
- long idx; \
+ long idx = end - tmp; /* temp var for remaining length (number of digits) */ \
\
- if (*tmp++=='0' && length>2) { /* don't accept numbers with leading zeros */ \
+ if (idx > MAX_LENGTH_OF_LONG - 1 || (*tmp++ == '0' && length > 2)) { \
+ /* don't accept numbers too long or with leading zeros */ \
break; \
} \
while (tmp<end) { \
tmp++; \
} \
if (tmp==end && *tmp=='\0') { /* a numeric index */ \
- if (*key=='-') { \
- idx = strtol(key, NULL, 10); \
- if (idx!=LONG_MIN) { \
- return func; \
- } \
- } else { \
- idx = strtol(key, NULL, 10); \
- if (idx!=LONG_MAX) { \
- return func; \
+ if (idx == MAX_LENGTH_OF_LONG - 1) { \
+ int cmp = strcmp(end - (MAX_LENGTH_OF_LONG - 1), long_min_digits); \
+ \
+ if (!(cmp < 0 || (cmp == 0 && *key == '-'))) { \
+ break; \
} \
} \
+ \
+ idx = strtol(key, NULL, 10); \
+ return func; \
} \
} while (0); \
}
#include "ext/bcmath/libbcmath/src/bcmath.h"
#endif
-#if SIZEOF_LONG == 4
-#define MAX_LENGTH_OF_LONG 11
-static const char long_min_digits[] = "2147483648";
-#elif SIZEOF_LONG == 8
-#define MAX_LENGTH_OF_LONG 20
-static const char long_min_digits[] = "9223372036854775808";
-#else
-#error "Unknown SIZEOF_LONG"
-#endif
-
-#define MAX_LENGTH_OF_DOUBLE 32
-
BEGIN_EXTERN_C()
ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
ZEND_API int sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);