-
Notifications
You must be signed in to change notification settings - Fork 626
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
Fix int32 overflow bugs with deep images #589
Conversation
A 32k x 32k image * 8 byte pointers leads to an overflow when trying to find the sample count of a deep pixel. Signed-off-by: Larry Gritz <[email protected]>
@@ -99,7 +99,7 @@ inline | |||
int& | |||
sampleCount(char* base, int xStride, int yStride, int x, int y) | |||
{ | |||
char* ptr = base + y * yStride + x * xStride; | |||
char* ptr = base + y * ptrdiff_t(yStride) + x * ptrdiff_t(xStride); |
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.
Wouldn't it be better to change the type of the function arguments to ptrdiff_t?
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.
I wanted something that could be easily folded into a 2.4.1 (or even backported earlier) without changing any function signatures. I can't wait until 2021 for this fix to proliferate into software that's widely used.
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.
But maybe a TODO item to scrub the whole API for places that should be upgraded from 32 to 64 bit ints next time we are willing to have very-breaking changes.
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.
Sounds fine.
Shall I merge this? |
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.
LGTM too
A 32k x 32k image * 8 byte pointers leads to an overflow when trying
to find the sample count of a deep pixel.
Signed-off-by: Larry Gritz [email protected]