[前][次][番号順一覧][スレッド一覧]

ruby-changes:60333

From: Koichi <ko1@a...>
Date: Mon, 9 Mar 2020 02:57:46 +0900 (JST)
Subject: [ruby-changes:60333] dff69bb462 (master): Cast properly for shift operand

https://git.ruby-lang.org/ruby.git/commit/?id=dff69bb462

From dff69bb46204cf9d0d1abfe9d6e76a1768fb9734 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Mon, 9 Mar 2020 02:53:46 +0900
Subject: Cast properly for shift operand

`(int) << RHASH_LEV_SHIFT` can be negative integer.

diff --git a/hash.c b/hash.c
index 4477ab5..62383a6 100644
--- a/hash.c
+++ b/hash.c
@@ -1434,7 +1434,7 @@ hash_iter_lev_inc(VALUE hash) https://github.com/ruby/ruby/blob/trunk/hash.c#L1434
     }
     else {
         lev += 1;
-        RBASIC(hash)->flags = ((RBASIC(hash)->flags & ~RHASH_LEV_MASK) | (lev << RHASH_LEV_SHIFT));
+        RBASIC(hash)->flags = ((RBASIC(hash)->flags & ~RHASH_LEV_MASK) | ((VALUE)lev << RHASH_LEV_SHIFT));
         if (lev == RHASH_LEV_MAX) {
             iter_lev_in_ivar_set(hash, lev);
         }
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]