diff options
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.230 2009/12/10 18:17:37 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.231 2009/12/11 13:40:44 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -346,12 +346,13 @@ static const char *generic_reader (lua_State *L, void *ud, size_t *size) { | |||
346 | static int luaB_load_aux (lua_State *L, int farg) { | 346 | static int luaB_load_aux (lua_State *L, int farg) { |
347 | int status; | 347 | int status; |
348 | Readstat stat; | 348 | Readstat stat; |
349 | const char *s = lua_tostring(L, farg); | 349 | size_t l; |
350 | const char *s = lua_tolstring(L, farg, &l); | ||
350 | stat.mode = luaL_optstring(L, farg + 2, "bt"); | 351 | stat.mode = luaL_optstring(L, farg + 2, "bt"); |
351 | if (s != NULL) { /* loading a string? */ | 352 | if (s != NULL) { /* loading a string? */ |
352 | const char *chunkname = luaL_optstring(L, farg + 1, s); | 353 | const char *chunkname = luaL_optstring(L, farg + 1, s); |
353 | status = (checkrights(L, stat.mode, s) != NULL) | 354 | status = (checkrights(L, stat.mode, s) != NULL) |
354 | || luaL_loadbuffer(L, s, lua_objlen(L, farg), chunkname); | 355 | || luaL_loadbuffer(L, s, l, chunkname); |
355 | } | 356 | } |
356 | else { /* loading from a reader function */ | 357 | else { /* loading from a reader function */ |
357 | const char *chunkname = luaL_optstring(L, farg + 1, "=(load)"); | 358 | const char *chunkname = luaL_optstring(L, farg + 1, "=(load)"); |