int alignment, currarg, adjusting, argnum, width, precision;
char *format, *result, padding;
int always_sign;
+ int format_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &args, &argc) == FAILURE) {
return NULL;
convert_to_string_ex(args[format_offset]);
format = Z_STRVAL_PP(args[format_offset]);
+ format_len = Z_STRLEN_PP(args[format_offset]);
result = emalloc(size);
currarg = 1;
- while (inpos<Z_STRLEN_PP(args[format_offset])) {
+ while (inpos<format_len) {
int expprec = 0, multiuse = 0;
zval *tmp;
/* space padding, the default */
} else if (format[inpos] == '+') {
always_sign = 1;
- } else if (format[inpos] == '\'') {
+ } else if (format[inpos] == '\'' && inpos+1<format_len) {
padding = format[++inpos];
} else {
PRINTF_DEBUG(("sprintf: end of modifiers\n"));