From e2fa2a1a4d2a675b309f09c43c0bcd711aff08e3 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Mon, 1 Aug 2016 14:18:13 +0800 Subject: [PATCH] lua5.3.3 bugfix 2/3 --- 3rd/lua/lcode.c | 4 ++-- 3rd/lua/loslib.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/3rd/lua/lcode.c b/3rd/lua/lcode.c index 0cd5600e..a97da8dc 100644 --- a/3rd/lua/lcode.c +++ b/3rd/lua/lcode.c @@ -1018,8 +1018,8 @@ static void codeunexpval (FuncState *fs, OpCode op, expdesc *e, int line) { */ static void codebinexpval (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2, int line) { - int rk1 = luaK_exp2RK(fs, e1); /* both operands are "RK" */ - int rk2 = luaK_exp2RK(fs, e2); + int rk2 = luaK_exp2RK(fs, e2); /* both operands are "RK" */ + int rk1 = luaK_exp2RK(fs, e1); freeexps(fs, e1, e2); e1->u.info = luaK_codeABC(fs, op, 0, rk1, rk2); /* generate opcode */ e1->k = VRELOCABLE; /* all those operations are relocatable */ diff --git a/3rd/lua/loslib.c b/3rd/lua/loslib.c index 48106555..a56877e1 100644 --- a/3rd/lua/loslib.c +++ b/3rd/lua/loslib.c @@ -260,7 +260,8 @@ static int getfield (lua_State *L, const char *key, int d, int delta) { static const char *checkoption (lua_State *L, const char *conv, char *buff) { const char *option; int oplen = 1; - for (option = LUA_STRFTIMEOPTIONS; *option != '\0'; option += oplen) { + int convlen = (int)strlen(conv); + for (option = LUA_STRFTIMEOPTIONS; *option != '\0' && oplen <= convlen; option += oplen) { if (*option == '|') /* next block? */ oplen++; /* next length */ else if (memcmp(conv, option, oplen) == 0) { /* match? */