summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2014-02-25 12:36:33 +0800
committerXinchen Hui <laruence@gmail.com>2014-02-25 12:36:33 +0800
commit9e4da2d0ec8be34abfd7a5c778bb4f94e3e939b5 (patch)
tree27d76857784cb1d300e9ec9a45b6d94dbdd33fc7 /ext
parentd35a068aa62d58454f7af6f5f657fe3ef9e54067 (diff)
downloadphp-git-9e4da2d0ec8be34abfd7a5c778bb4f94e3e939b5.tar.gz
Fixed segfault in ext/standard/tests/strings/money_format_variation1.phpt
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/string.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 84ce342aed..405168ce4e 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -5422,10 +5422,11 @@ PHP_FUNCTION(str_word_count)
Convert monetary value(s) to string */
PHP_FUNCTION(money_format)
{
- int format_len = 0, str_len;
- char *format, *str, *p, *e;
+ int format_len = 0;
+ char *format, *p, *e;
double value;
zend_bool check = 0;
+ zend_string *str;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sd", &format, &format_len, &value) == FAILURE) {
return;
@@ -5445,16 +5446,14 @@ PHP_FUNCTION(money_format)
}
}
- str_len = format_len + 1024;
- str = emalloc(str_len);
- if ((str_len = strfmon(str, str_len, format, value)) < 0) {
- efree(str);
+ str = STR_ALLOC(format_len + 1024, 0);
+ if ((str->len = strfmon(str->val, str->len, format, value)) < 0) {
+ STR_FREE(str);
RETURN_FALSE;
}
- str[str_len] = 0;
+ str->val[str->len] = '\0';
-//??? RETURN_STRINGL(erealloc(str, str_len + 1), str_len, 0);
- RETURN_STRINGL(erealloc(str, str_len + 1), str_len);
+ RETURN_STR(STR_REALLOC(str, str->len, 0));
}
/* }}} */
#endif