diff options
author | Mike Pall <mike> | 2022-05-20 11:54:20 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2022-05-20 11:54:20 +0200 |
commit | 80bb1428aad72d870af9969c30c9c39b174b5a59 (patch) | |
tree | 4a58fa86f02792a2a20e9aaac3d370a05c9e9dec /src/host | |
parent | 91bc6b8ad1f373c1ce9003dc024b2e21fad0e444 (diff) | |
download | luajit-80bb1428aad72d870af9969c30c9c39b174b5a59.tar.gz luajit-80bb1428aad72d870af9969c30c9c39b174b5a59.tar.bz2 luajit-80bb1428aad72d870af9969c30c9c39b174b5a59.zip |
Fix loop initialization in table.foreach().
Reported by Daniel Steinberg.
Diffstat (limited to 'src/host')
-rw-r--r-- | src/host/buildvm_libbc.h | 60 | ||||
-rw-r--r-- | src/host/genlibbc.lua | 7 |
2 files changed, 35 insertions, 32 deletions
diff --git a/src/host/buildvm_libbc.h b/src/host/buildvm_libbc.h index b2600bd5..8f07f436 100644 --- a/src/host/buildvm_libbc.h +++ b/src/host/buildvm_libbc.h | |||
@@ -8,37 +8,37 @@ static const uint8_t libbc_code[] = { | |||
8 | 0,1,2,24,1,0,0,76,1,2,0,243,244,148,165,20,198,190,199,252,3,0,1,2,0,0,0,3, | 8 | 0,1,2,24,1,0,0,76,1,2,0,243,244,148,165,20,198,190,199,252,3,0,1,2,0,0,0,3, |
9 | 16,0,5,0,21,1,0,0,76,1,2,0,0,2,10,0,0,0,15,16,0,12,0,16,1,9,0,41,2,1,0,21,3, | 9 | 16,0,5,0,21,1,0,0,76,1,2,0,0,2,10,0,0,0,15,16,0,12,0,16,1,9,0,41,2,1,0,21,3, |
10 | 0,0,41,4,1,0,77,2,8,128,18,6,1,0,18,8,5,0,59,9,5,0,66,6,3,2,10,6,0,0,88,7,1, | 10 | 0,0,41,4,1,0,77,2,8,128,18,6,1,0,18,8,5,0,59,9,5,0,66,6,3,2,10,6,0,0,88,7,1, |
11 | 128,76,6,2,0,79,2,248,127,75,0,1,0,0,2,11,0,0,0,16,16,0,12,0,16,1,9,0,43,2, | 11 | 128,76,6,2,0,79,2,248,127,75,0,1,0,0,2,11,0,0,1,16,16,0,12,0,16,1,9,0,43,2, |
12 | 0,0,18,3,0,0,41,4,0,0,88,5,7,128,18,7,1,0,18,9,5,0,18,10,6,0,66,7,3,2,10,7, | 12 | 0,0,18,3,0,0,42,4,0,0,88,5,7,128,18,7,1,0,18,9,5,0,18,10,6,0,66,7,3,2,10,7, |
13 | 0,0,88,8,1,128,76,7,2,0,70,5,3,3,82,5,247,127,75,0,1,0,0,1,2,0,0,0,3,16,0,12, | 13 | 0,0,88,8,1,128,76,7,2,0,70,5,3,3,82,5,247,127,75,0,1,0,1,255,255,249,255,15, |
14 | 0,21,1,0,0,76,1,2,0,0,2,10,0,0,2,30,16,0,12,0,21,2,0,0,11,1,0,0,88,3,7,128, | 14 | 0,1,2,0,0,0,3,16,0,12,0,21,1,0,0,76,1,2,0,0,2,10,0,0,2,30,16,0,12,0,21,2,0, |
15 | 8,2,0,0,88,3,23,128,59,3,2,0,43,4,0,0,64,4,2,0,76,3,2,0,88,3,18,128,16,1,14, | 15 | 0,11,1,0,0,88,3,7,128,8,2,0,0,88,3,23,128,59,3,2,0,43,4,0,0,64,4,2,0,76,3,2, |
16 | 0,41,3,1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3,12,128,59,3,1,0,22,4,1,1,18,5,2, | 16 | 0,88,3,18,128,16,1,14,0,41,3,1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3,12,128,59, |
17 | 0,41,6,1,0,77,4,4,128,23,8,1,7,59,9,7,0,64,9,8,0,79,4,252,127,43,4,0,0,64,4, | 17 | 3,1,0,22,4,1,1,18,5,2,0,41,6,1,0,77,4,4,128,23,8,1,7,59,9,7,0,64,9,8,0,79,4, |
18 | 2,0,76,3,2,0,75,0,1,0,0,2,0,5,12,0,0,0,35,16,0,12,0,16,1,14,0,16,2,14,0,16, | 18 | 252,127,43,4,0,0,64,4,2,0,76,3,2,0,75,0,1,0,0,2,0,5,12,0,0,0,35,16,0,12,0,16, |
19 | 3,14,0,11,4,0,0,88,5,1,128,18,4,0,0,16,4,12,0,3,1,2,0,88,5,24,128,33,5,1,3, | 19 | 1,14,0,16,2,14,0,16,3,14,0,11,4,0,0,88,5,1,128,18,4,0,0,16,4,12,0,3,1,2,0,88, |
20 | 0,2,3,0,88,6,4,128,2,3,1,0,88,6,2,128,4,4,0,0,88,6,9,128,18,6,1,0,18,7,2,0, | 20 | 5,24,128,33,5,1,3,0,2,3,0,88,6,4,128,2,3,1,0,88,6,2,128,4,4,0,0,88,6,9,128, |
21 | 41,8,1,0,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79,6,252,127,88,6,8,128, | 21 | 18,6,1,0,18,7,2,0,41,8,1,0,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79,6,252, |
22 | 18,6,2,0,18,7,1,0,41,8,255,255,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79, | 22 | 127,88,6,8,128,18,6,2,0,18,7,1,0,41,8,255,255,77,6,4,128,32,10,5,9,59,11,9, |
23 | 6,252,127,76,4,2,0,0 | 23 | 0,64,11,10,4,79,6,252,127,76,4,2,0,0 |
24 | #else | 24 | #else |
25 | 0,1,2,0,0,1,2,24,1,0,0,76,1,2,0,241,135,158,166,3,220,203,178,130,4,0,1,2,0, | 25 | 0,1,2,0,0,1,2,24,1,0,0,76,1,2,0,241,135,158,166,3,220,203,178,130,4,0,1,2,0, |
26 | 0,1,2,24,1,0,0,76,1,2,0,243,244,148,165,20,198,190,199,252,3,0,1,2,0,0,0,3, | 26 | 0,1,2,24,1,0,0,76,1,2,0,243,244,148,165,20,198,190,199,252,3,0,1,2,0,0,0,3, |
27 | 16,0,5,0,21,1,0,0,76,1,2,0,0,2,9,0,0,0,15,16,0,12,0,16,1,9,0,41,2,1,0,21,3, | 27 | 16,0,5,0,21,1,0,0,76,1,2,0,0,2,9,0,0,0,15,16,0,12,0,16,1,9,0,41,2,1,0,21,3, |
28 | 0,0,41,4,1,0,77,2,8,128,18,6,1,0,18,7,5,0,59,8,5,0,66,6,3,2,10,6,0,0,88,7,1, | 28 | 0,0,41,4,1,0,77,2,8,128,18,6,1,0,18,7,5,0,59,8,5,0,66,6,3,2,10,6,0,0,88,7,1, |
29 | 128,76,6,2,0,79,2,248,127,75,0,1,0,0,2,10,0,0,0,16,16,0,12,0,16,1,9,0,43,2, | 29 | 128,76,6,2,0,79,2,248,127,75,0,1,0,0,2,10,0,0,1,16,16,0,12,0,16,1,9,0,43,2, |
30 | 0,0,18,3,0,0,41,4,0,0,88,5,7,128,18,7,1,0,18,8,5,0,18,9,6,0,66,7,3,2,10,7,0, | 30 | 0,0,18,3,0,0,42,4,0,0,88,5,7,128,18,7,1,0,18,8,5,0,18,9,6,0,66,7,3,2,10,7,0, |
31 | 0,88,8,1,128,76,7,2,0,70,5,3,3,82,5,247,127,75,0,1,0,0,1,2,0,0,0,3,16,0,12, | 31 | 0,88,8,1,128,76,7,2,0,70,5,3,3,82,5,247,127,75,0,1,0,1,255,255,249,255,15,0, |
32 | 0,21,1,0,0,76,1,2,0,0,2,10,0,0,2,30,16,0,12,0,21,2,0,0,11,1,0,0,88,3,7,128, | 32 | 1,2,0,0,0,3,16,0,12,0,21,1,0,0,76,1,2,0,0,2,10,0,0,2,30,16,0,12,0,21,2,0,0, |
33 | 8,2,0,0,88,3,23,128,59,3,2,0,43,4,0,0,64,4,2,0,76,3,2,0,88,3,18,128,16,1,14, | 33 | 11,1,0,0,88,3,7,128,8,2,0,0,88,3,23,128,59,3,2,0,43,4,0,0,64,4,2,0,76,3,2,0, |
34 | 0,41,3,1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3,12,128,59,3,1,0,22,4,1,1,18,5,2, | 34 | 88,3,18,128,16,1,14,0,41,3,1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3,12,128,59,3, |
35 | 0,41,6,1,0,77,4,4,128,23,8,1,7,59,9,7,0,64,9,8,0,79,4,252,127,43,4,0,0,64,4, | 35 | 1,0,22,4,1,1,18,5,2,0,41,6,1,0,77,4,4,128,23,8,1,7,59,9,7,0,64,9,8,0,79,4,252, |
36 | 2,0,76,3,2,0,75,0,1,0,0,2,0,5,12,0,0,0,35,16,0,12,0,16,1,14,0,16,2,14,0,16, | 36 | 127,43,4,0,0,64,4,2,0,76,3,2,0,75,0,1,0,0,2,0,5,12,0,0,0,35,16,0,12,0,16,1, |
37 | 3,14,0,11,4,0,0,88,5,1,128,18,4,0,0,16,4,12,0,3,1,2,0,88,5,24,128,33,5,1,3, | 37 | 14,0,16,2,14,0,16,3,14,0,11,4,0,0,88,5,1,128,18,4,0,0,16,4,12,0,3,1,2,0,88, |
38 | 0,2,3,0,88,6,4,128,2,3,1,0,88,6,2,128,4,4,0,0,88,6,9,128,18,6,1,0,18,7,2,0, | 38 | 5,24,128,33,5,1,3,0,2,3,0,88,6,4,128,2,3,1,0,88,6,2,128,4,4,0,0,88,6,9,128, |
39 | 41,8,1,0,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79,6,252,127,88,6,8,128, | 39 | 18,6,1,0,18,7,2,0,41,8,1,0,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79,6,252, |
40 | 18,6,2,0,18,7,1,0,41,8,255,255,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79, | 40 | 127,88,6,8,128,18,6,2,0,18,7,1,0,41,8,255,255,77,6,4,128,32,10,5,9,59,11,9, |
41 | 6,252,127,76,4,2,0,0 | 41 | 0,64,11,10,4,79,6,252,127,76,4,2,0,0 |
42 | #endif | 42 | #endif |
43 | }; | 43 | }; |
44 | 44 | ||
@@ -48,9 +48,9 @@ static const struct { const char *name; int ofs; } libbc_map[] = { | |||
48 | {"string_len",50}, | 48 | {"string_len",50}, |
49 | {"table_foreachi",69}, | 49 | {"table_foreachi",69}, |
50 | {"table_foreach",136}, | 50 | {"table_foreach",136}, |
51 | {"table_getn",207}, | 51 | {"table_getn",213}, |
52 | {"table_remove",226}, | 52 | {"table_remove",232}, |
53 | {"table_move",355}, | 53 | {"table_move",361}, |
54 | {NULL,502} | 54 | {NULL,508} |
55 | }; | 55 | }; |
56 | 56 | ||
diff --git a/src/host/genlibbc.lua b/src/host/genlibbc.lua index f6dabbec..072a7495 100644 --- a/src/host/genlibbc.lua +++ b/src/host/genlibbc.lua | |||
@@ -55,7 +55,7 @@ local function transform_lua(code) | |||
55 | end) | 55 | end) |
56 | code = string.gsub(code, "PAIRS%((.-)%)", function(var) | 56 | code = string.gsub(code, "PAIRS%((.-)%)", function(var) |
57 | fixup.PAIRS = true | 57 | fixup.PAIRS = true |
58 | return format("nil, %s, 0", var) | 58 | return format("nil, %s, 0x4dp80", var) |
59 | end) | 59 | end) |
60 | return "return "..code, fixup | 60 | return "return "..code, fixup |
61 | end | 61 | end |
@@ -129,7 +129,10 @@ local function fixup_dump(dump, fixup) | |||
129 | end | 129 | end |
130 | p = p + 4 | 130 | p = p + 4 |
131 | end | 131 | end |
132 | return ffi.string(start, n) | 132 | local ndump = ffi.string(start, n) |
133 | -- Fixup hi-part of 0x4dp80 to LJ_KEYINDEX. | ||
134 | ndump = ndump:gsub("\x80\x80\xcd\xaa\x04", "\xff\xff\xf9\xff\x0f") | ||
135 | return ndump | ||
133 | end | 136 | end |
134 | 137 | ||
135 | local function find_defs(src) | 138 | local function find_defs(src) |