Skip to content

Commit

Permalink
internal_memscan: add extra check
Browse files Browse the repository at this point in the history
  • Loading branch information
lethosor committed Feb 4, 2017
1 parent f65a981 commit a8f4833
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/LuaApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2557,6 +2557,9 @@ static int internal_memscan(lua_State *L)
for (int i = 0; i <= hcount; i++)
{
uint8_t *p = haystack + i*hstep;
if (p + nsize > haystack + (hcount * hstep)) {
break;
}
if (memcmp(p, needle, nsize) == 0) {
lua_pushinteger(L, i);
lua_pushinteger(L, (lua_Integer)p);
Expand Down

0 comments on commit a8f4833

Please sign in to comment.