From: Ilia Alshanetsky Date: Tue, 29 Aug 2006 14:32:16 +0000 (+0000) Subject: Finalize implode() patch X-Git-Tag: php-5.2.0RC3~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7c618c40bc098c74c471bb772227e21a4edfc7cb;p=php Finalize implode() patch --- diff --git a/ext/standard/string.c b/ext/standard/string.c index 8e5fb6f819..9bb8304b8e 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -905,7 +905,7 @@ PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value TSRMLS_DC) case IS_LONG: { char stmp[MAX_LENGTH_OF_LONG + 1]; - str_len = sprintf(stmp, "%ld", Z_LVAL_PP(tmp)); + str_len = snprintf(stmp, sizeof(stmp), "%ld", Z_LVAL_PP(tmp)); smart_str_appendl(&implstr, stmp, str_len); } break; @@ -920,11 +920,10 @@ PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value TSRMLS_DC) break; case IS_DOUBLE: { - char *stmp; - stmp = emalloc(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1); - str_len = sprintf(stmp, "%.*G", (int) EG(precision), Z_DVAL_PP(tmp)); + char *stmp = (char *) do_alloca(MAX_LENGTH_OF_DOUBLE + EG(precision) + 2); /* +1 for decimal point */ + str_len = snprintf(stmp, sizeof(stmp), "%.*G", (int) EG(precision), Z_DVAL_PP(tmp)); smart_str_appendl(&implstr, stmp, str_len); - efree(stmp); + free_alloca(stmp); } break;