Skip to content

mprintf: avoid never-ending loop for positive-infinite - #22713

Closed
bagder wants to merge 1 commit into
masterfrom
bagder/mprintf-inf
Closed

bagder wants to merge 1 commit into
masterfrom
bagder/mprintf-inf

Conversation

@bagder

@bagder bagder commented Aug 27, 2026

Copy link
Copy Markdown
Member

Floating point is odd but it features this concept of "infinite" (which can happen with the new typecast from long double to double) and apparently dividing infinite with 10 is still infinte.

Follow-up to bdda3a2

Pointed out by: Codex Security

Floating point is odd but it features this concept of "infinite" (which
can happen with the new typecast from long double to double) and
apparently dividing infinite with 10 is still infinte.

Follow-up to bdda3a2

Pointed out by: Codex Security
@bagder
bagder marked this pull request as ready for review August 27, 2026 21:27
@bagder
bagder requested a lite review from Copilot August 27, 2026 21:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a potential never-ending loop in lib/mprintf.c when formatting positive infinity as a floating-point number. It does so by ensuring the digit-reduction loop is bounded by the remaining precision budget (maxprec), preventing infinite values from causing non-terminating behavior.

Changes:

  • Bound the while(val >= 10.0) loop with maxprec to guarantee termination even when val is +inf.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bagder bagder closed this in 282057f Aug 27, 2026
@bagder
bagder deleted the bagder/mprintf-inf branch August 27, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants