Skip to content

Commit

Permalink
Fix int32 overflow bugs with deep images
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
lgritz committed Oct 25, 2019
1 parent 486ff10 commit e53ebd3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions OpenEXR/IlmImf/ImfMisc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
int* intPtr = (int*) ptr;

return *intPtr;
Expand All @@ -110,7 +110,7 @@ inline
const int&
sampleCount(const char* base, int xStride, int yStride, int x, int y)
{
const char* ptr = base + y * yStride + x * xStride;
const char* ptr = base + y * ptrdiff_t(yStride) + x * ptrdiff_t(xStride);
int* intPtr = (int*) ptr;

return *intPtr;
Expand Down

0 comments on commit e53ebd3

Please sign in to comment.