diff options
| -rw-r--r-- | ext/standard/formatted_print.c | 8 | ||||
| -rw-r--r-- | ext/standard/tests/strings/bug22207.phpt | 11 | 
2 files changed, 17 insertions, 2 deletions
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index d5bd95c4b7..b53d5e3072 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -359,8 +359,12 @@ php_sprintf_appenddouble(char **buffer, int *pos,  		numbuf[i++] = fmt;  		exp_p = php_convert_to_decimal(decpt, 0, &dec2, &sign, 0);  		numbuf[i++] = sign ? '-' : '+'; -		while (*exp_p) { -			numbuf[i++] = *(exp_p++); +		if (*exp_p) {  +			while (*exp_p) { +				numbuf[i++] = *(exp_p++); +			} +		} else { +			numbuf[i++] = '0';  		}  	} else {  		numbuf[i++] = cvt[j++]; diff --git a/ext/standard/tests/strings/bug22207.phpt b/ext/standard/tests/strings/bug22207.phpt new file mode 100644 index 0000000000..1623fb8e41 --- /dev/null +++ b/ext/standard/tests/strings/bug22207.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #22207 (missing 0 when using the e notation in *printf functions) +--FILE-- +<?php +	printf("%10.5e\n", 1.1);  +	var_dump(sprintf("%10.5e\n", 1.1)); +?> +--EXPECT-- +1.1000e+0 +string(17) "       1.1000e+0 +"  | 
