Skip to content

Add check for "." being parsed with exponent E#136

Merged
Dream-Master merged 1 commit into
masterfrom
fix_expression_crash
Jun 9, 2026
Merged

Add check for "." being parsed with exponent E#136
Dream-Master merged 1 commit into
masterfrom
fix_expression_crash

Conversation

@Miklebe

@Miklebe Miklebe commented Jun 7, 2026

Copy link
Copy Markdown

As mentioned in GTNH discord https://discord.com/channels/181078474394566657/1303308397961019472/1513223411009327419

BigDecimal parser crashes when it's given string like "1E9.0" because "." is not a digit. Adds a check inside numberOfString so this doesn't happen, works for complex stuff like 5+1e5.0+15*1.8, where it fails and zeroes only 1e5.0 part. Another way would be to add the checks to parseExpressionWholeNumber and parseExpression, in which case i think it would fail the entire string and return 0.
Unless i am understanding it wrong, second option would be "faster" because we have less if else statements in the numberOfString that gets called for each number in the expression at the "cost" of failing the entire string.

@TheYoingLad TheYoingLad 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.

Looks good!

@Dream-Master Dream-Master merged commit 7a446d7 into master Jun 9, 2026
1 check passed
@Dream-Master Dream-Master deleted the fix_expression_crash branch June 9, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants