Skip to content

Commit 121da2e

Browse files
fix printf(%%) case
1 parent 353d28f commit 121da2e

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

Zend/zend_compile.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4966,20 +4966,8 @@ static zend_result zend_compile_func_printf(znode *result, zend_ast_list *args)
49664966
/* Check if there are any format specifiers */
49674967
char *p = Z_STRVAL_P(format_string);
49684968
char *end = p + Z_STRLEN_P(format_string);
4969-
bool has_format_specs = false;
49704969

4971-
while (p < end) {
4972-
if (*p == '%') {
4973-
p++;
4974-
if (p < end && *p != '%') {
4975-
has_format_specs = true;
4976-
break;
4977-
}
4978-
}
4979-
p++;
4980-
}
4981-
4982-
if (!has_format_specs) {
4970+
if (!memchr(p, '%', end - p)) {
49834971
/* No format specifiers - just emit ECHO and return string length */
49844972
znode format_node;
49854973
zend_compile_expr(&format_node, args->child[0]);

0 commit comments

Comments
 (0)