diff options
Diffstat (limited to 'lstrlib.c')
-rw-r--r-- | lstrlib.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.138 2007/10/29 15:51:10 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.139 2007/11/12 14:10:09 roberto Exp roberto $ |
3 | ** Standard library for string operations and pattern-matching | 3 | ** Standard library for string operations and pattern-matching |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -499,7 +499,10 @@ static int str_find_aux (lua_State *L, int find) { | |||
499 | const char *p = luaL_checklstring(L, 2, &l2); | 499 | const char *p = luaL_checklstring(L, 2, &l2); |
500 | size_t init = posrelat(luaL_optinteger(L, 3, 1), l1); | 500 | size_t init = posrelat(luaL_optinteger(L, 3, 1), l1); |
501 | if (init < 1) init = 1; | 501 | if (init < 1) init = 1; |
502 | else if (init > l1) init = l1 + 1; | 502 | else if (init > l1 + 1) { /* start after string's end? */ |
503 | lua_pushnil(L); /* cannot find anything */ | ||
504 | return 1; | ||
505 | } | ||
503 | if (find && (lua_toboolean(L, 4) || /* explicit request? */ | 506 | if (find && (lua_toboolean(L, 4) || /* explicit request? */ |
504 | strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ | 507 | strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ |
505 | /* do a plain search */ | 508 | /* do a plain search */ |