summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/php_variables.c14
-rw-r--r--main/spprintf.c27
2 files changed, 22 insertions, 19 deletions
diff --git a/main/php_variables.c b/main/php_variables.c
index 1d57ceda28..d8277d267a 100644
--- a/main/php_variables.c
+++ b/main/php_variables.c
@@ -283,8 +283,8 @@ static inline int add_post_vars(zval *arr, post_var_data_t *vars, zend_bool eof
{
uint64_t max_vars = PG(max_input_vars);
- vars->ptr = vars->str.c;
- vars->end = vars->str.c + vars->str.len;
+ vars->ptr = vars->str.s->val;
+ vars->end = vars->str.s->val + vars->str.s->len;
while (add_post_var(arr, vars, eof TSRMLS_CC)) {
if (++vars->cnt > max_vars) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
@@ -296,7 +296,7 @@ static inline int add_post_vars(zval *arr, post_var_data_t *vars, zend_bool eof
}
if (!eof) {
- memmove(vars->str.c, vars->ptr, vars->str.len = vars->end - vars->ptr);
+ memmove(vars->str.s->val, vars->ptr, vars->str.s->len = vars->end - vars->ptr);
}
return SUCCESS;
}
@@ -318,8 +318,8 @@ SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler)
smart_str_appendl(&post_data.str, buf, len);
if (SUCCESS != add_post_vars(arr, &post_data, 0 TSRMLS_CC)) {
- if (post_data.str.c) {
- efree(post_data.str.c);
+ if (post_data.str.s) {
+ smart_str_free(&post_data.str);
}
return;
}
@@ -331,8 +331,8 @@ SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler)
}
add_post_vars(arr, &post_data, 1 TSRMLS_CC);
- if (post_data.str.c) {
- efree(post_data.str.c);
+ if (post_data.str.s) {
+ smart_str_free(&post_data.str);
}
}
}
diff --git a/main/spprintf.c b/main/spprintf.c
index 5b16d51441..dfee6d9612 100644
--- a/main/spprintf.c
+++ b/main/spprintf.c
@@ -145,13 +145,13 @@
* Macro that does padding. The padding is done by printing
* the character ch.
*/
-#define PAD(xbuf, count, ch) do { \
- if ((count) > 0) { \
- size_t newlen; \
- smart_str_alloc(xbuf, (count), 0); \
- memset(xbuf->c + xbuf->len, ch, (count)); \
- xbuf->len += (count); \
- } \
+#define PAD(xbuf, count, ch) do { \
+ if ((count) > 0) { \
+ size_t newlen; \
+ smart_str_alloc(xbuf, (count), 0); \
+ memset(xbuf->s->val + xbuf->s->len, ch, (count)); \
+ xbuf->s->len += (count); \
+ } \
} while (0)
#define NUM(c) (c - '0')
@@ -700,7 +700,7 @@ static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap)
case 'n':
- *(va_arg(ap, int *)) = xbuf->len;
+ *(va_arg(ap, int *)) = xbuf->s->len;
goto skip_output;
/*
@@ -795,17 +795,20 @@ skip_output:
PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) /* {{{ */
{
smart_str xbuf = {0};
+ int result;
xbuf_format_converter(&xbuf, format, ap);
- if (max_len && xbuf.len > max_len) {
- xbuf.len = max_len;
+ if (max_len && xbuf.s->len > max_len) {
+ xbuf.s->len = max_len;
}
smart_str_0(&xbuf);
- *pbuf = xbuf.c;
+ *pbuf = estrndup(xbuf.s->val, xbuf.s->len);
+ result = xbuf.s->len;
+ smart_str_free(&xbuf);
- return xbuf.len;
+ return result;
}
/* }}} */