Merge lp:~gero-bare/midori/midori-fix-undef-behavior into lp:midori
Proposed by
Gero.Bare
Status: | Merged |
---|---|
Approved by: | Cris Dywan |
Approved revision: | 6829 |
Merged at revision: | 6841 |
Proposed branch: | lp:~gero-bare/midori/midori-fix-undef-behavior |
Merge into: | lp:midori |
Diff against target: |
34 lines (+14/-3) 1 file modified
extensions/mouse-gestures.c (+14/-3) |
To merge this branch: | bzr merge lp:~gero-bare/midori/midori-fix-undef-behavior |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cris Dywan | Approve | ||
Review via email:
|
This proposal supersedes a proposal from 2014-11-05.
Commit message
Fix undefined behavior uint in mouse gestures
Description of the change
Fix two undefined behaviors.
First fix subtraction of two unsigned int. If the second operand is greater than the first, the result wraps around starting at MAX_UINT with is probably way more than intended.
Cast Double to Float. M_PI is a double which means promotes all the operation to double, but because the function fabsf takes a float, the result is truncated to float risking to give an erroneous answer.
To post a comment you must log in.
11 + //Remember x1,x2,y1,y2 are guint unsigned integers
12 + //substract a greater number from a lower is undefined
13 + //this guard that.
Good explanation. However please use correct English grammar.
// Remember that x1, x2, y1 and y2 are guint unsigned integers.
// Subtracting a greater number from a lower one is undefined.
// This guards against that.
14 + if ( x1 > x2)
18 + if ( y1 > y2)
Please use no space after the opening brace ie. "if (y1 > y2)".
30 + if (fabsf (angle - dir_angle) < DEVIANCE || fabsf (angle - dir_angle + 2 *(float)(M_PI)) < DEVIANCE)
Please leave a space after the asterisk ie. "+ 2 * (float)(M_PI)".
Sorry to be nit picking. With these stylistic changes it'll be good to go!