Bug 1383492: stylo: Change nscoord_MAX to 1<<30 - 1 ; r?emilio,dbaron draft
authorManish Goregaokar <manishearth@gmail.com>
Tue, 25 Jul 2017 14:36:33 -0700
changeset 615408 a2c7c4db0b8aa48e921b1d5972c438d796d27723
parent 615406 7e8b0a455ef5e28721b2e19f00f75e7e9652ec5e
child 639165 b181f195ca8bd39869c8bc3fc54c006eed48c629
push id70346
push userbmo:manishearth@gmail.com
push dateTue, 25 Jul 2017 22:38:50 +0000
reviewersemilio, dbaron
bugs1383492
milestone56.0a1
Bug 1383492: stylo: Change nscoord_MAX to 1<<30 - 1 ; r?emilio,dbaron nscoord_MAX is (1<<30) so that we can check for overflow *after* adding two nscoords. However, (nscoord_MAX + nscoord_MAX) will still overflow. Subtracting one makes this no longer possible. MozReview-Commit-ID: BtbQRMp5kWm
gfx/src/nsCoord.h
--- a/gfx/src/nsCoord.h
+++ b/gfx/src/nsCoord.h
@@ -41,17 +41,17 @@ inline bool NS_IEEEIsNan(float aF) {
     (pun.mBits & 0x007FFFFF) != 0;
 }
 
 #ifdef NS_COORD_IS_FLOAT
 typedef float nscoord;
 #define nscoord_MAX NS_IEEEPositiveInfinity()
 #else
 typedef int32_t nscoord;
-#define nscoord_MAX nscoord(1 << 30)
+#define nscoord_MAX nscoord((1 << 30) - 1)
 #endif
 
 #define nscoord_MIN (-nscoord_MAX)
 
 inline void VERIFY_COORD(nscoord aCoord) {
 #ifdef NS_COORD_IS_FLOAT
   NS_ASSERTION(floorf(aCoord) == aCoord,
                "Coords cannot have fractions");