diff options
| author | Lua Team <team@lua.org> | 2013-11-11 12:00:00 +0000 |
|---|---|---|
| committer | repogen <> | 2013-11-11 12:00:00 +0000 |
| commit | 357e7cdc32cd4224b03748e4f284857e47f70a68 (patch) | |
| tree | 43dd992e668609554251ce6b69df4c29d560835e /src/lbitlib.c | |
| parent | dc27609467d2699ac9252e89d632432ac5f798f2 (diff) | |
| download | lua-github-5.2.3.tar.gz | |
Diffstat (limited to 'src/lbitlib.c')
| -rw-r--r-- | src/lbitlib.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lbitlib.c b/src/lbitlib.c index 9637532e..31c7b66f 100644 --- a/src/lbitlib.c +++ b/src/lbitlib.c @@ -1,5 +1,5 @@ /* -** $Id: lbitlib.c,v 1.18 2013/03/19 13:19:12 roberto Exp $ +** $Id: lbitlib.c,v 1.18.1.2 2013/07/09 18:01:41 roberto Exp $ ** Standard library for bitwise operations ** See Copyright Notice in lua.h */ @@ -129,7 +129,8 @@ static int b_rot (lua_State *L, int i) { b_uint r = luaL_checkunsigned(L, 1); i &= (LUA_NBITS - 1); /* i = i % NBITS */ r = trim(r); - r = (r << i) | (r >> (LUA_NBITS - i)); + if (i != 0) /* avoid undefined shift of LUA_NBITS when i == 0 */ + r = (r << i) | (r >> (LUA_NBITS - i)); lua_pushunsigned(L, trim(r)); return 1; } |
