summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Kew <jfkthame@googlemail.com>2019-09-11 12:07:46 +0000
committerJonathan Kew <jfkthame@googlemail.com>2019-09-11 12:07:46 +0000
commitd60b0af5e32fed034bd163d244148947d3ed91a8 (patch)
tree808aca2740bcc6d9f9a6b5dd6c8e7cca3e48bdd9
parentafc6c935f1b52ca74d96f1ea2cbfb3e47ffb7fd4 (diff)
downloadpixman-d60b0af5e32fed034bd163d244148947d3ed91a8.tar.gz
Avoid undefined behavior (left-shifting negative value) in pixman_int_to_fixed
Reported in https://bugzilla.mozilla.org/show_bug.cgi?id=1580352. Casting the argument to uint32_t should avoid invoking undefined behavior here. We'll still have *implementation-defined* behavior when casting the result back to pixman_fixed_t, but that's better than *undefined*.
-rw-r--r--pixman/pixman.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/pixman/pixman.h b/pixman/pixman.h
index 62dfb6a..8b38ba7 100644
--- a/pixman/pixman.h
+++ b/pixman/pixman.h
@@ -127,7 +127,7 @@ typedef pixman_fixed_16_16_t pixman_fixed_t;
#define pixman_fixed_1_minus_e (pixman_fixed_1 - pixman_fixed_e)
#define pixman_fixed_minus_1 (pixman_int_to_fixed(-1))
#define pixman_fixed_to_int(f) ((int) ((f) >> 16))
-#define pixman_int_to_fixed(i) ((pixman_fixed_t) ((i) << 16))
+#define pixman_int_to_fixed(i) ((pixman_fixed_t) ((uint32_t) (i) << 16))
#define pixman_fixed_to_double(f) (double) ((f) / (double) pixman_fixed_1)
#define pixman_double_to_fixed(d) ((pixman_fixed_t) ((d) * 65536.0))
#define pixman_fixed_frac(f) ((f) & pixman_fixed_1_minus_e)