static zend_string *
php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC)
{
+ zval *newargs = NULL;
zval *args, *z_format;
int argc, size = 240, inpos = 0, outpos = 0, temppos;
int alignment, currarg, adjusting, argnum, width, precision;
if (use_array) {
int i = 1;
- zval *newargs, *zv;
+ zval *zv;
zval array;
z_format = &args[format_offset];
if (argnum <= 0) {
efree(result);
+ if (newargs) {
+ efree(newargs);
+ }
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument number must be greater than zero");
return NULL;
}
PRINTF_DEBUG(("sprintf: getting width\n"));
if ((width = php_sprintf_getnumber(format, &inpos)) < 0) {
efree(result);
+ if (newargs) {
+ efree(newargs);
+ }
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Width must be greater than zero and less than %d", INT_MAX);
return NULL;
}
if (isdigit((int)format[inpos])) {
if ((precision = php_sprintf_getnumber(format, &inpos)) < 0) {
efree(result);
+ if (newargs) {
+ efree(newargs);
+ }
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Precision must be greater than zero and less than %d", INT_MAX);
return NULL;
}
if (argnum >= argc) {
efree(result);
+ if (newargs) {
+ efree(newargs);
+ }
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too few arguments");
return NULL;
}
}
}
+ if (newargs) {
+ efree(newargs);
+ }
+
/* possibly, we have to make sure we have room for the terminating null? */
result->val[outpos]=0;
result->len = outpos;