argnum = php_sprintf_getnumber(&format, &format_len);
if (argnum <= 0) {
- zend_string_efree(result);
zend_value_error("Argument number must be greater than zero");
- return NULL;
+ goto fail;
}
argnum--;
format++; /* skip the '$' */
padding = *format;
} else {
zend_value_error("Missing padding character");
- zend_string_efree(result);
- return NULL;
+ goto fail;
}
} else {
PRINTF_DEBUG(("sprintf: end of modifiers\n"));
if (isdigit((int)*format)) {
PRINTF_DEBUG(("sprintf: getting width\n"));
if ((width = php_sprintf_getnumber(&format, &format_len)) < 0) {
- efree(result);
zend_value_error("Width must be greater than zero and less than %d", INT_MAX);
- return NULL;
+ goto fail;
}
adjusting |= ADJ_WIDTH;
} else {
PRINTF_DEBUG(("sprintf: getting precision\n"));
if (isdigit((int)*format)) {
if ((precision = php_sprintf_getnumber(&format, &format_len)) < 0) {
- efree(result);
zend_value_error("Precision must be greater than zero and less than %d", INT_MAX);
- return NULL;
+ goto fail;
}
adjusting |= ADJ_PRECISION;
expprec = 1;
}
if (max_missing_argnum >= 0) {
- efree(result);
if (nb_additional_parameters == -1) {
zend_value_error("The arguments array must contain %d items, %d given", max_missing_argnum + 1, argc);
} else {
zend_argument_count_error("%d parameters are required, %d given", max_missing_argnum + nb_additional_parameters + 1, argc + nb_additional_parameters);
}
- return NULL;
+ goto fail;
}
exit:
ZSTR_VAL(result)[outpos]=0;
ZSTR_LEN(result) = outpos;
return result;
+
+fail:
+ zend_string_efree(result);
+ return NULL;
}
/* }}} */