From 1e17bb2aab4e954b52704221d407891bc019e039 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Wed, 4 Aug 2010 23:11:44 +0000 Subject: [PATCH] - Fixed bug #52534 (var_export array with negative key) --- NEWS | 1 + ext/standard/tests/array/bug52534.phpt | 14 ++++++++++++++ ext/standard/var.c | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/array/bug52534.phpt diff --git a/NEWS b/NEWS index c14c38282d..ef5acfba5a 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2010, PHP 5.3.4 +- Fixed bug #52534 (var_export array with negative key). (Felipe) - Fixed bug #52508 (newline problem with parse_ini_file+INI_SCANNER_RAW). (Felipe) - Fixed bug #52487 (PDO::FETCH_INTO leaks memory). (Felipe) diff --git a/ext/standard/tests/array/bug52534.phpt b/ext/standard/tests/array/bug52534.phpt new file mode 100644 index 0000000000..dfff3fdb4f --- /dev/null +++ b/ext/standard/tests/array/bug52534.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #52534 (var_export array with negative key) +--FILE-- + 'Hello'); + +var_export($aArray); + +?> +--EXPECT-- +array ( + -1 => 'Hello', +) diff --git a/ext/standard/var.c b/ext/standard/var.c index 3479dc4b8f..87493fd62b 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -353,7 +353,7 @@ static int php_array_element_export(zval **zv TSRMLS_DC, int num_args, va_list a if (hash_key->nKeyLength == 0) { /* numeric key */ buffer_append_spaces(buf, level+1); - smart_str_append_long(buf, hash_key->h); + smart_str_append_long(buf, (long) hash_key->h); smart_str_appendl(buf, " => ", 4); } else { /* string key */ char *key, *tmp_str; -- 2.40.0