Skip to content

ext/intl: IntlNumberFormatter::format() unbounded allocation on expon… - #24443

Closed
devnexen wants to merge 3 commits into
php:masterfrom
devnexen:intl_numfmt_decimal_exponent
Closed

devnexen wants to merge 3 commits into
php:masterfrom
devnexen:intl_numfmt_decimal_exponent

Conversation

@devnexen

Copy link
Copy Markdown
Member

…ent strings.

A numeric string such as "1e999999999" made ICU expand every digit outside ZendMM, ignoring memory_limit. Strings in exponent notation are now rejected, so the output stays proportional to the input length.

…ent strings.

A numeric string such as "1e999999999" made ICU expand every digit outside
ZendMM, ignoring memory_limit. Strings in exponent notation are now rejected,
so the output stays proportional to the input length.
@devnexen
devnexen marked this pull request as ready for review October 19, 2026 19:06
@devnexen
devnexen requested a review from LamentXU123 as a code owner October 19, 2026 19:06
@LamentXU123

Copy link
Copy Markdown
Member

Can scale/ in skeletons also have this bug?

@iliaal iliaal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we probably should handle the scale/* case here too as it has the same type of issue:

$f = IntlNumberFormatter::createFromSkeleton('precision-unlimited scale/1e3000000', 'en_US');
var_dump(strlen($f->format(1)));    // int(4000001)
var_dump(strlen($f->format(1.0)));  // int(4000001)
var_dump(strlen($f->format('1')));  // int(4000001)

@devnexen

Copy link
Copy Markdown
Member Author

completely forgot this PR since last days, I think I have changes locally

@iliaal iliaal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now, thanks for the scale/ fix.

Perhaps worth mentioning the scale/ fix in UPGRADING as well?

@devnexen devnexen closed this in d0fc966 Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants