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: an overflow bug for div2_round #7

Merged
merged 4 commits into from Jan 22, 2018
Merged

fix: an overflow bug for div2_round #7

merged 4 commits into from Jan 22, 2018

Conversation

cutezerocat
Copy link
Contributor

There is a potential overflow bug for div2_round function.

When parameter a of function div2_round (in vireo/imagecore/utils/mathutils.h) has the maximum value, the result is 0 which is incorrect.

There is a potential overflow bug for div2_round function.

When parameter a of function div2_round has the maximum value, the result is 0 which is incorrect.
@CLAassistant
Copy link

CLAassistant commented Dec 18, 2017

CLA assistant check
All committers have signed the CLA.

@@ -111,5 +112,8 @@ inline void swap(unsigned int& a, unsigned int& b)

inline unsigned int div2_round(unsigned int a)
{
return (a + 1) / 2;
if (a == UINT_MAX)
Copy link
Contributor

@canbal canbal Dec 22, 2017

Choose a reason for hiding this comment

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

Please use the following format

if (condition) {
	// do first thing
} else {
	// do second thing
}

@canbal
Copy link
Contributor

canbal commented Dec 22, 2017

@lukealonso this looks correct to me but please chime in as the primary owner for this piece of code.

As required by the coding style, parentheses are added to the if statement in the previous commit.
@cutezerocat
Copy link
Contributor Author

@canbal @lukealonso done.

Small style changes. Looks good, going to merge.
@canbal canbal merged commit 4a5b40d into twitter:master Jan 22, 2018
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