diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-07-05 15:02:28 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-07-05 15:02:28 -0300 |
commit | 48735da0d035d0a24f67b499ae888b824993c0fe (patch) | |
tree | 4a388ae685ec29b2302df9afc770a7abce66083a | |
parent | 2b4bd21585c15a25fdf7dee6ae7a4fc98916112a (diff) | |
download | lua-48735da0d035d0a24f67b499ae888b824993c0fe.tar.gz lua-48735da0d035d0a24f67b499ae888b824993c0fe.tar.bz2 lua-48735da0d035d0a24f67b499ae888b824993c0fe.zip |
When loading a file, Lua may call the reader function again after
it returned end of input + luac listings choke on long strings
-rw-r--r-- | bugs | 80 |
1 files changed, 78 insertions, 2 deletions
@@ -1880,8 +1880,8 @@ patch = [[ | |||
1880 | +++ lundump.c 2008/04/04 19:51:41 2.7.1.4 | 1880 | +++ lundump.c 2008/04/04 19:51:41 2.7.1.4 |
1881 | @@ -1,5 +1,5 @@ | 1881 | @@ -1,5 +1,5 @@ |
1882 | /* | 1882 | /* |
1883 | -** $Id: bugs,v 1.123 2013/05/13 16:17:47 roberto Exp roberto $ | 1883 | -** $Id: bugs,v 1.124 2013/05/16 16:03:50 roberto Exp roberto $ |
1884 | +** $Id: bugs,v 1.123 2013/05/13 16:17:47 roberto Exp roberto $ | 1884 | +** $Id: bugs,v 1.124 2013/05/16 16:03:50 roberto Exp roberto $ |
1885 | ** load precompiled Lua chunks | 1885 | ** load precompiled Lua chunks |
1886 | ** See Copyright Notice in lua.h | 1886 | ** See Copyright Notice in lua.h |
1887 | */ | 1887 | */ |
@@ -2409,6 +2409,57 @@ patch = [[ | |||
2409 | } | 2409 | } |
2410 | 2410 | ||
2411 | 2411 | ||
2412 | Bug{ | ||
2413 | what = [[When loading a file, | ||
2414 | Lua may call the reader function again after it returned end of input | ||
2415 | ]], | ||
2416 | report = [[Chris Howie, 2013/06/05]], | ||
2417 | since = [[5.1]], | ||
2418 | fix = [[5.2]], | ||
2419 | example = [[ | ||
2420 | load(function () print("called"); return nil end) | ||
2421 | --> called | ||
2422 | --> called (should be called only once!) | ||
2423 | ]], | ||
2424 | patch = [[ | ||
2425 | --- lzio.h 2007/12/27 13:02:25 1.21.1.1 | ||
2426 | +++ lzio.h 2013/07/04 13:55:59 | ||
2427 | @@ -59,6 +59,7 @@ | ||
2428 | lua_Reader reader; | ||
2429 | void* data; /* additional data */ | ||
2430 | lua_State *L; /* Lua state (for reader) */ | ||
2431 | + int eoz; /* true if reader has no more data */ | ||
2432 | }; | ||
2433 | |||
2434 | |||
2435 | --- lzio.c 2007/12/27 13:02:25 1.31.1.1 | ||
2436 | +++ lzio.c 2013/07/04 13:53:06 | ||
2437 | @@ -22,10 +22,14 @@ | ||
2438 | size_t size; | ||
2439 | lua_State *L = z->L; | ||
2440 | const char *buff; | ||
2441 | + if (z->eoz) return EOZ; | ||
2442 | lua_unlock(L); | ||
2443 | buff = z->reader(L, z->data, &size); | ||
2444 | lua_lock(L); | ||
2445 | - if (buff == NULL || size == 0) return EOZ; | ||
2446 | + if (buff == NULL || size == 0) { | ||
2447 | + z->eoz = 1; /* avoid calling reader function next time */ | ||
2448 | + return EOZ; | ||
2449 | + } | ||
2450 | z->n = size - 1; | ||
2451 | z->p = buff; | ||
2452 | return char2int(*(z->p++)); | ||
2453 | @@ -51,6 +55,7 @@ | ||
2454 | z->data = data; | ||
2455 | z->n = 0; | ||
2456 | z->p = NULL; | ||
2457 | + z->eoz = 0; | ||
2458 | } | ||
2459 | ]] | ||
2460 | } | ||
2461 | |||
2462 | |||
2412 | ----------------------------------------------------------------- | 2463 | ----------------------------------------------------------------- |
2413 | -- Lua 5.2.0 | 2464 | -- Lua 5.2.0 |
2414 | 2465 | ||
@@ -3025,6 +3076,31 @@ patch = [[ | |||
3025 | ]] | 3076 | ]] |
3026 | } | 3077 | } |
3027 | 3078 | ||
3079 | Bug{ | ||
3080 | what = [[luac listings choke on long strings]], | ||
3081 | report = [[Ashwin Hirschi, 2013/07/03]], | ||
3082 | since = [[5.1.2]], | ||
3083 | fix = nil, | ||
3084 | example = [[ | ||
3085 | -- When you call 'luac -l' over this chunk, it chokes the output | ||
3086 | s="Lorem ipsum dolor sit amet, consectetur, " | ||
3087 | ]], | ||
3088 | patch = [[ | ||
3089 | --- luac.c 2011-11-29 15:46:33 -0200 1.69 | ||
3090 | +++ luac.c 2013-07-03 21:26:01 -0300 | ||
3091 | @@ -251,7 +251,7 @@ | ||
3092 | static void PrintConstant(const Proto* f, int i) | ||
3093 | { | ||
3094 | const TValue* o=&f->k[i]; | ||
3095 | - switch (ttype(o)) | ||
3096 | + switch (ttypenv(o)) | ||
3097 | { | ||
3098 | case LUA_TNIL: | ||
3099 | printf("nil"); | ||
3100 | ]] | ||
3101 | } | ||
3102 | |||
3103 | |||
3028 | --[=[ | 3104 | --[=[ |
3029 | Bug{ | 3105 | Bug{ |
3030 | what = [[ ]], | 3106 | what = [[ ]], |