-
Notifications
You must be signed in to change notification settings - Fork 566
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(raw): Avoid buffer overrun for flip direction cases #4100
Conversation
If you are looping i over range [0,width), and want index to go the other direction, you need `index = width - 1 - i`, not `index = width - i`. Identified by Sonar static analysis. Signed-off-by: Larry Gritz <lg@larrygritz.com>
@@ -1505,7 +1505,7 @@ RawInput::read_native_scanline(int subimage, int miplevel, int y, int /*z*/, | |||
// to the array direction so we must copy the pixels into a temporary contiguous buffer | |||
else if (sizes.flip == 5 /*90 degrees CCW*/ | |||
|| sizes.flip == 6 /*90 degrees CW*/) { | |||
scanline_start = m_spec.height - y + sizes.left_margin; | |||
scanline_start = m_spec.height - 1 - y + sizes.left_margin; |
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.
Does the scanline_start
expression on Line 1496 also need the -1
adjustment?
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 believe you are correct, I will fix there as well
Signed-off-by: Larry Gritz <lg@larrygritz.com>
@Shootfast I would love your opinion on this. |
LGTM! |
…areFoundation#4100) If you are looping i over range [0,width), and want index to go the other direction, you need `index = width - 1 - i`, not `index = width - i`. Identified by Sonar static analysis. --------- Signed-off-by: Larry Gritz <lg@larrygritz.com>
…areFoundation#4100) If you are looping i over range [0,width), and want index to go the other direction, you need `index = width - 1 - i`, not `index = width - i`. Identified by Sonar static analysis. --------- Signed-off-by: Larry Gritz <lg@larrygritz.com> Signed-off-by: Peter Kovář <peter.kovar@reflexion.tv>
If you are looping i over range [0,width), and want index to go the other direction, you need
index = width - 1 - i
, notindex = width - i
.Identified by Sonar static analysis.