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
=== modified file 'src/miral/window_info.cpp'
--- src/miral/window_info.cpp 2017-09-15 11:00:10 +0000
+++ src/miral/window_info.cpp 2017-09-29 14:17:35 +0000
@@ -304,7 +304,8 @@
304 {304 {
305 auto const ar = min_aspect();305 auto const ar = min_aspect();
306306
307 auto const error = new_size.height.as_int()*long(ar.width) - new_size.width.as_int()*long(ar.height);307 auto const error = new_size.height.as_int()*static_cast<long long>(ar.width) -
308 new_size.width.as_int() *static_cast<long long>(ar.height);
308309
309 if (error > 0)310 if (error > 0)
310 {311 {
@@ -326,7 +327,8 @@
326 {327 {
327 auto const ar = max_aspect();328 auto const ar = max_aspect();
328329
329 auto const error = new_size.width.as_int()*long(ar.height) - new_size.height.as_int()*long(ar.width);330 auto const error = new_size.width.as_int() *static_cast<long long>(ar.height) -
331 new_size.height.as_int()*static_cast<long long>(ar.width);
330332
331 if (error > 0)333 if (error > 0)
332 {334 {

Subscribers

People subscribed via source and target branches