Skip to content
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

Merged
merged 1 commit into from
Oct 23, 2019

Conversation

lgritz
Copy link
Contributor

@lgritz lgritz commented Oct 18, 2019

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 lg@imageworks.com

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 <lg@imageworks.com>
@@ -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);
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

@cary-ilm cary-ilm left a comment

Choose a reason for hiding this comment

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

Sounds fine.

@lgritz
Copy link
Contributor Author

lgritz commented Oct 22, 2019

Shall I merge this?

Copy link
Contributor

@peterhillman peterhillman left a comment

Choose a reason for hiding this comment

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

LGTM too

@lgritz lgritz merged commit eadfbf8 into AcademySoftwareFoundation:master Oct 23, 2019
@lgritz lgritz deleted the lg-bigdeep branch October 23, 2019 22:16
@cary-ilm cary-ilm added this to the v2.4.1 milestone Feb 7, 2020
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.

None yet

3 participants