-
Notifications
You must be signed in to change notification settings - Fork 215
mp_radix off-by-one error and other related code-cleanup #439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
One more remark: ((y == 0xff) || (y >= radix)). The check for y == 0xff is redundant, because the radix is already checked before to be between 2 and 64. So if y == 0xff, it will be >= radix for sure. |
|
Good find! |
|
You might only want to reformat the table 😁 |
|
|
minad
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
Sorry, I disagree, it's reduntant. But maybe my explanation is not described well enough. If I'm wrong, then you should be able to trigger the ill-behavior with a new test-case. ... (the radix conversions could use some more test-cases anyway ....) |
|
Ah sorry I agree with you. With reformatting I meant, reformat such that every line is 10 numbers. My eyes are a bit hurt by how it looks now. |
Done! Indeed, looks better now! |
|
@sjaeckel Good to merge? |
|
@sjaeckel ping? |
c779ff2 to
bbb1780
Compare
Noted an off-by-one error, testing for MP_RMAP_REVERSE_SIZE < pos. Explanation: If MP_RMAP_REVERSE_SIZE == pos this returns false, so the code continues to read the table. Lucky, this only happens when the char value is 128, which is impossible for signed characters. So, this bug can actually only happen on a system with unsigned characters.
Further on, I noted various other tiny mistakes, e.g. the use of SIZE_MAX in stead of the real available bffer-size. Also the s_mp_rmap_reverse table can be reduced 8 in lenght, if we start with '+' in stead of with '('. This branch contains all I found related to mp_radix stuff.
Anyway, I hope you like this clean-up.