Patch implode-log10-bug-fix02 for Scripting Engine problem Bug #72100
Patch version 2016-04-25 09:12 UTC
Return to Bug #72100 |
Download this patch
Patch Revisions:
Developer: mikhail.galanin@yahoo.com
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 45f2de4..2feb8e5 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -1233,12 +1233,22 @@ PHPAPI void php_implode(const zend_string *delim, zval *arr, zval *return_value)
*++strptr = NULL;
((zend_long *) (strings + numelems))[strptr - strings] = Z_LVAL_P(tmp);
if (val < 0) {
+ val = -val;
+ len++;
+ }
+ if (val < 0) {
val = -10 * val;
}
if (val < 10) {
len++;
+ } else if (val > 100000000000) {
+ zend_long long_val = Z_LVAL_P(tmp);
+ do {
+ len++;
+ long_val /= 10;
+ } while(long_val != 0);
} else {
- len += (int) log10(10 * (double) val);
+ len += (int)log10(val) + 1;
}
} else {
*++strptr = zval_get_string(tmp);
|