diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2008-05-08 13:55:08 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2008-05-08 13:55:08 -0300 |
commit | a3af42de8e65d8ac70684242589ca5e30c73c548 (patch) | |
tree | 4ec484a5bc8a7d6c5bfa8cd3a4d0fc6eb2d9f659 | |
parent | 198be23f36466496228bdbceac2d4b8c01e3c21c (diff) | |
download | lua-a3af42de8e65d8ac70684242589ca5e30c73c548.tar.gz lua-a3af42de8e65d8ac70684242589ca5e30c73c548.tar.bz2 lua-a3af42de8e65d8ac70684242589ca5e30c73c548.zip |
patch for "blow stack" bug
-rw-r--r-- | bugs | 32 |
1 files changed, 30 insertions, 2 deletions
@@ -1875,7 +1875,35 @@ function crash(depth) | |||
1875 | end | 1875 | end |
1876 | for i=1,25 do print(i); crash(i) end | 1876 | for i=1,25 do print(i); crash(i) end |
1877 | ]], | 1877 | ]], |
1878 | patch = [[ ]], | 1878 | patch = [[ |
1879 | --- lundump.c 2008/04/04 16:00:45 2.7.1.3 | ||
1880 | +++ lundump.c 2008/04/04 19:51:41 2.7.1.4 | ||
1881 | @@ -1,5 +1,5 @@ | ||
1882 | /* | ||
1883 | -** $Id: lundump.c,v 2.7.1.3 2008/04/04 16:00:45 roberto Exp $ | ||
1884 | +** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $ | ||
1885 | ** load precompiled Lua chunks | ||
1886 | ** See Copyright Notice in lua.h | ||
1887 | */ | ||
1888 | @@ -161,7 +161,9 @@ | ||
1889 | |||
1890 | static Proto* LoadFunction(LoadState* S, TString* p) | ||
1891 | { | ||
1892 | - Proto* f=luaF_newproto(S->L); | ||
1893 | + Proto* f; | ||
1894 | + if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep"); | ||
1895 | + f=luaF_newproto(S->L); | ||
1896 | setptvalue2s(S->L,S->L->top,f); incr_top(S->L); | ||
1897 | f->source=LoadString(S); if (f->source==NULL) f->source=p; | ||
1898 | f->linedefined=LoadInt(S); | ||
1899 | @@ -175,6 +177,7 @@ | ||
1900 | LoadDebug(S,f); | ||
1901 | IF (!luaG_checkcode(f), "bad code"); | ||
1902 | S->L->top--; | ||
1903 | + S->L->nCcalls--; | ||
1904 | return f; | ||
1905 | } | ||
1906 | ]], | ||
1879 | } | 1907 | } |
1880 | 1908 | ||
1881 | Bug{ | 1909 | Bug{ |
@@ -1905,7 +1933,7 @@ patch = [[ | |||
1905 | + have the same value of an invalid setlist; so, we must | 1933 | + have the same value of an invalid setlist; so, we must |
1906 | + go all the way back to the first of them (if any) */ | 1934 | + go all the way back to the first of them (if any) */ |
1907 | + for (j = 0; j < dest; j++) { | 1935 | + for (j = 0; j < dest; j++) { |
1908 | + Instruction d = pt->code[dest-1]; | 1936 | + Instruction d = pt->code[dest-1-j]; |
1909 | + if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break; | 1937 | + if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break; |
1910 | + } | 1938 | + } |
1911 | + /* if 'j' is even, previous value is not a setlist (even if | 1939 | + /* if 'j' is even, previous value is not a setlist (even if |