Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix a possible infinite loop by incrementing one of the variables used in the loop conditional. #934

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

Closed
wants to merge 1 commit into from

Conversation

idealisms
Copy link

Fix a possible infinite loop by incrementing one of the variables used in the loop conditional.

This was detected by Richard Trieu when compiling with clang.

@mdboom
Copy link
Member

mdboom commented Jun 7, 2012

Good catch. This should probably go on the v1.1.x branch.

@@ -1067,7 +1067,7 @@
double r, g, b, alpha;
const size_t N = imo->rowsIn * imo->colsIn;
size_t i = 0;
while (i < N)
while (i++ < N)
Copy link
Member

Choose a reason for hiding this comment

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

Why don't we just say

for (size_t i = 0; i < N; ++i)

to make it even more obvious there's nothing special about this loop.

Copy link
Author

Choose a reason for hiding this comment

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

A for loop would be fine too. We were just trying to keep with the original style.

…d in the loop conditional.

This was detected by Richard Trieu when compiling with clang.
@@ -1066,8 +1066,7 @@
int rgba = A->dimensions[2] == 4;
double r, g, b, alpha;
const size_t N = imo->rowsIn * imo->colsIn;
size_t i = 0;
while (i < N)
for (size_t i = 0; i < N; ++i)
Copy link
Author

Choose a reason for hiding this comment

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

Updated to use a for loop.

@jdh2358
Copy link
Collaborator

jdh2358 commented Jun 8, 2012

@idealisms Could you rebase this against the v1.1.x branch so it can make it into the upcoming release?

@mdboom
Copy link
Member

mdboom commented Jun 8, 2012

I'm closing this, since it's been merged in to v1.1.x and will be merged into master on the next v1.1.x merge.

@mdboom mdboom closed this Jun 8, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants