Mir

Merge lp:~brandontschaefer/mir/avoid-overflowing-use-long-long into lp:mir

Proposed by Brandon Schaefer on 2017-09-29
Status: Merged
Merged at revision: 4277
Proposed branch: lp:~brandontschaefer/mir/avoid-overflowing-use-long-long
Merge into: lp:mir
Diff against target: 23 lines (+4/-2)
1 file modified
src/miral/window_info.cpp (+4/-2)
To merge this branch: bzr merge lp:~brandontschaefer/mir/avoid-overflowing-use-long-long
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Needs Fixing on 2017-09-29
Alan Griffiths Approve on 2017-09-29
Chris Halse Rogers 2017-09-29 Approve on 2017-09-29
Review via email: mp+331571@code.launchpad.net

Commit message

When we have sizeof(long) == sizeof(int) on armhf/i386 we are storing max::long as the max_aspect then we multiple the max::long * <some_value> which ends up overflowing. For now we'll just cast to long long giving us at lease 64bits.

Description of the change

When we have sizeof(long) == sizeof(int) on armhf/i386 we are storing max::long as the max_aspect then we multiple the max::long * <some_value> which ends up overflowing. For now we'll just cast to long long giving us at lease 64bits.

To post a comment you must log in.
Chris Halse Rogers (raof) wrote :

Sure, as long as we actually fix this later.

review: Approve
Alan Griffiths (alan-griffiths) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/miral/window_info.cpp'
2--- src/miral/window_info.cpp 2017-09-15 11:00:10 +0000
3+++ src/miral/window_info.cpp 2017-09-29 14:17:35 +0000
4@@ -304,7 +304,8 @@
5 {
6 auto const ar = min_aspect();
7
8- auto const error = new_size.height.as_int()*long(ar.width) - new_size.width.as_int()*long(ar.height);
9+ auto const error = new_size.height.as_int()*static_cast<long long>(ar.width) -
10+ new_size.width.as_int() *static_cast<long long>(ar.height);
11
12 if (error > 0)
13 {
14@@ -326,7 +327,8 @@
15 {
16 auto const ar = max_aspect();
17
18- auto const error = new_size.width.as_int()*long(ar.height) - new_size.height.as_int()*long(ar.width);
19+ auto const error = new_size.width.as_int() *static_cast<long long>(ar.height) -
20+ new_size.height.as_int()*static_cast<long long>(ar.width);
21
22 if (error > 0)
23 {

Subscribers

People subscribed via source and target branches