~gerboland/miral/release-patched

« back to all changes in this revision

Viewing changes to miral/window_info.cpp

  • Committer: Gerry Boland
  • Date: 2017-09-13 13:22:44 UTC
  • Revision ID: gerry.boland@canonical.com-20170913132244-c58ghe6jqbiuhejo
Avoid div by zero

Show diffs side-by-side

added added

removed removed

Lines of Context:
272
272
 
273
273
        auto const error = new_size.height.as_int()*long(ar.width) - new_size.width.as_int()*long(ar.height);
274
274
 
275
 
        if (error > 0)
 
275
        if (error > 0 && ar.height > 0 && ar.width > 0)
276
276
        {
277
277
            // Add (denominator-1) to numerator to ensure rounding up
278
278
            auto const width_correction  = (error+(ar.height-1))/ar.height;
294
294
 
295
295
        auto const error = new_size.width.as_int()*long(ar.height) - new_size.height.as_int()*long(ar.width);
296
296
 
297
 
        if (error > 0)
 
297
        if (error > 0 && ar.height > 0 && ar.width > 0)
298
298
        {
299
299
            // Add (denominator-1) to numerator to ensure rounding up
300
300
            auto const height_correction = (error+(ar.width-1))/ar.width;