Repository navigation
fix(conversions): reject non-hex digits in HexToOct.hexToDecimal - #7748
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7748 +/- ##
=========================================
Coverage 82.33% 82.34%
- Complexity 8444 8445 +1
=========================================
Files 843 843
Lines 26154 26156 +2
Branches 5109 5110 +1
=========================================
+ Hits 21535 21537 +2
Misses 3830 3830
Partials 789 789 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
kevin9327
marked this pull request as ready for review
November 11, 2026 20:22
kevin9327
requested review from
DenizAltunkapan,
alxkm and
yanglbme
as code owners
November 11, 2026 20:22
alxkm
approved these changes
Nov 11, 2026
alxkm
left a comment
Member
There was a problem hiding this comment.
Looks good, thanks for the contribution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HexToOct.hexToDecimallooks each character up withindexOfand uses the result directly, so a character that is not a hex digit adds-1instead of failing. The method then returns a wrong number with no error:hexToDecimal("1G")returns15(16 * 1 + -1)hexToDecimal("0x1A")returns-230hexToOctal("Z")returns0(the-1makesdecimalToOctalskip its loop)This change throws
IllegalArgumentExceptionfor any character outside0-9A-F(after the existing upper-casing), matching whatOctalToHexadecimal.octalToDecimalalready does for bad octal digits. Valid inputs give the same results as before.HexToOctTest.testInvalidHexDigitThrowscovers the three inputs above. It fails onmasterand passes with this change; the existing tests still pass.clang-format -i --style=file path/to/your/file.javaI used an AI assistant while preparing this change; I reviewed the code and ran the tests myself.