Merge branch 'PHP-8.4'

* PHP-8.4:
  Fix GH-15964: printf() can strip sign of -INF
This commit is contained in:
Christoph M. Becker 2024-12-02 14:28:23 +01:00
commit 3b517e0825
No known key found for this signature in database
GPG key ID: D66C9593118BCCB6
2 changed files with 8 additions and 3 deletions

View file

@ -247,8 +247,9 @@ php_sprintf_appenddouble(zend_string **buffer, size_t *pos,
if (zend_isinf(number)) { if (zend_isinf(number)) {
is_negative = (number<0); is_negative = (number<0);
php_sprintf_appendstring(buffer, pos, "INF", 3, 0, padding, char *str = is_negative ? "-INF" : "INF";
alignment, 3, is_negative, 0, always_sign); php_sprintf_appendstring(buffer, pos, str, strlen(str), 0, padding,
alignment, strlen(str), is_negative, 0, always_sign);
return; return;
} }

View file

@ -44,6 +44,8 @@ try {
} catch(\ValueError $e) { } catch(\ValueError $e) {
print('Error found: '.$e->getMessage()."\n"); print('Error found: '.$e->getMessage()."\n");
} }
printf("printf test 31:%.17g\n", INF);
printf("printf test 32:%.17g\n", -INF);
vprintf("vprintf test 1:%2\$-2d %1\$2d\n", array(1, 2)); vprintf("vprintf test 1:%2\$-2d %1\$2d\n", array(1, 2));
@ -83,4 +85,6 @@ printf test 27:3 1 2
printf test 28:02 1 printf test 28:02 1
printf test 29:2 1 printf test 29:2 1
printf test 30:Error found: Argument number specifier must be greater than zero and less than 2147483647 printf test 30:Error found: Argument number specifier must be greater than zero and less than 2147483647
printf test 31:INF
printf test 32:-INF
vprintf test 1:2 1 vprintf test 1:2 1