Jarkko Korpi : widl: Fix overflow when left-shifting.

Alexandre Julliard julliard at winehq.org
Thu Jun 23 11:15:24 CDT 2016


Module: wine
Branch: master
Commit: bb9b2f33ae5894478ef509fae3f4b8e24267682a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=bb9b2f33ae5894478ef509fae3f4b8e24267682a

Author: Jarkko Korpi <jarkko_korpi at hotmail.com>
Date:   Tue Jun 21 09:23:22 2016 +0300

widl: Fix overflow when left-shifting.

Signed-off-by: Jarkko Korpi <jarkko_korpi at hotmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 tools/widl/expr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/widl/expr.c b/tools/widl/expr.c
index 0ada012..cf97c7e 100644
--- a/tools/widl/expr.c
+++ b/tools/widl/expr.c
@@ -222,8 +222,8 @@ expr_t *make_exprt(enum expr_type type, var_t *var, expr_t *expr)
             e->is_const = TRUE;
             if (is_signed_integer_type(tref))
             {
-                cast_mask = (1 << (cast_type_bits - 1)) - 1;
-                if (expr->cval & (1 << (cast_type_bits - 1)))
+                cast_mask = (1u << (cast_type_bits - 1)) - 1;
+                if (expr->cval & (1u << (cast_type_bits - 1)))
                     e->cval = -((-expr->cval) & cast_mask);
                 else
                     e->cval = expr->cval & cast_mask;
@@ -231,8 +231,8 @@ expr_t *make_exprt(enum expr_type type, var_t *var, expr_t *expr)
             else
             {
                 /* calculate ((1 << cast_type_bits) - 1) avoiding overflow */
-                cast_mask = ((1 << (cast_type_bits - 1)) - 1) |
-                            1 << (cast_type_bits - 1);
+                cast_mask = ((1u << (cast_type_bits - 1)) - 1) |
+                            1u << (cast_type_bits - 1);
                 e->cval = expr->cval & cast_mask;
             }
         }




More information about the wine-cvs mailing list