diff options
Diffstat (limited to 'apps/plugins/lua/rocklib.c')
-rw-r--r-- | apps/plugins/lua/rocklib.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index 8c662b7359..3c38440850 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c | |||
@@ -642,8 +642,8 @@ RB_WRAP(strncasecmp) | |||
642 | 642 | ||
643 | static int mem_read_write(lua_State *L, uintptr_t address, size_t maxsize) | 643 | static int mem_read_write(lua_State *L, uintptr_t address, size_t maxsize) |
644 | { | 644 | { |
645 | intptr_t offset = (intptr_t) luaL_optint(L, 1, 0); | 645 | intptr_t offset = (intptr_t) luaL_optnumber(L, 1, 0); |
646 | size_t size = (size_t) luaL_optint(L, 2, maxsize); | 646 | size_t size = (size_t) luaL_optnumber(L, 2, maxsize); |
647 | size_t written; | 647 | size_t written; |
648 | int type = lua_type(L, 3); | 648 | int type = lua_type(L, 3); |
649 | 649 | ||
@@ -651,6 +651,7 @@ static int mem_read_write(lua_State *L, uintptr_t address, size_t maxsize) | |||
651 | { | 651 | { |
652 | /* allows pointer within structure to be calculated offset */ | 652 | /* allows pointer within structure to be calculated offset */ |
653 | offset = -(address + offset); | 653 | offset = -(address + offset); |
654 | luaL_argcheck(L, ((size_t) offset) <= maxsize, 1, ERR_IDX_RANGE); | ||
654 | size = (size_t) maxsize - offset; | 655 | size = (size_t) maxsize - offset; |
655 | } | 656 | } |
656 | 657 | ||