diff options
author | Dmitry Stogov <dmitry@zend.com> | 2016-04-26 13:04:06 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2016-04-26 13:04:06 +0300 |
commit | 8f0ceb97cff0defa74294c5580e93386897b4933 (patch) | |
tree | 752bde7b669aa8e77b551da65f4e1fa7d6a1117d /ext/standard/string.c | |
parent | 92233dd736a883c34d5769081a9c0ff6d9f264f7 (diff) | |
download | php-git-8f0ceb97cff0defa74294c5580e93386897b4933.tar.gz |
Fixed bug #72100 (implode() inserts garbage into resulting string when joins very big integer). (Mikhail Galanin)
Diffstat (limited to 'ext/standard/string.c')
-rw-r--r-- | ext/standard/string.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c index 3f47e73c1d..7ee918c2fe 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1229,16 +1229,16 @@ PHPAPI void php_implode(const zend_string *delim, zval *arr, zval *return_value) ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(arr), tmp) { if (Z_TYPE_P(tmp) == IS_LONG) { - double val = Z_LVAL_P(tmp); + zend_long val = Z_LVAL_P(tmp); + *++strptr = NULL; ((zend_long *) (strings + numelems))[strptr - strings] = Z_LVAL_P(tmp); - if (val < 0) { - val = -10 * val; + if (val <= 0) { + len++; } - if (val < 10) { + while (val) { + val /= 10; len++; - } else { - len += (int) log10(10 * (double) val); } } else { *++strptr = zval_get_string(tmp); |