diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib_string.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lib_string.c b/src/lib_string.c index d894f9f4..9c4cee8b 100644 --- a/src/lib_string.c +++ b/src/lib_string.c | |||
| @@ -487,10 +487,16 @@ static int str_find_aux(lua_State *L, int find) | |||
| 487 | const char *s = luaL_checklstring(L, 1, &l1); | 487 | const char *s = luaL_checklstring(L, 1, &l1); |
| 488 | const char *p = luaL_checklstring(L, 2, &l2); | 488 | const char *p = luaL_checklstring(L, 2, &l2); |
| 489 | ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1; | 489 | ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1; |
| 490 | if (init < 0) | 490 | if (init < 0) { |
| 491 | init = 0; | 491 | init = 0; |
| 492 | else if ((size_t)(init) > l1) | 492 | } else if ((size_t)(init) > l1) { |
| 493 | #if LJ_52 | ||
| 494 | setnilV(L->top-1); | ||
| 495 | return 1; | ||
| 496 | #else | ||
| 493 | init = (ptrdiff_t)l1; | 497 | init = (ptrdiff_t)l1; |
| 498 | #endif | ||
| 499 | } | ||
| 494 | if (find && (lua_toboolean(L, 4) || /* explicit request? */ | 500 | if (find && (lua_toboolean(L, 4) || /* explicit request? */ |
| 495 | strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ | 501 | strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ |
| 496 | /* do a plain search */ | 502 | /* do a plain search */ |
