aboutsummaryrefslogtreecommitdiff
path: root/src/vm_x86.dasc
diff options
context:
space:
mode:
authorMike Pall <mike>2023-11-12 14:42:24 +0100
committerMike Pall <mike>2023-11-12 14:42:24 +0100
commita4c1640432a9d8a60624cdc8065b15078c228e36 (patch)
treea0c6f0d4fe83927dff1f7042a077631c1bcf52c1 /src/vm_x86.dasc
parent65c849390702b1150d52e64db86cbc6b3c98413e (diff)
downloadluajit-a4c1640432a9d8a60624cdc8065b15078c228e36.tar.gz
luajit-a4c1640432a9d8a60624cdc8065b15078c228e36.tar.bz2
luajit-a4c1640432a9d8a60624cdc8065b15078c228e36.zip
Add stack check to pcall/xpcall.
Analyzed by Peter Cawley. #1048
Diffstat (limited to 'src/vm_x86.dasc')
-rw-r--r--src/vm_x86.dasc6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/vm_x86.dasc b/src/vm_x86.dasc
index 56712f90..811d5e75 100644
--- a/src/vm_x86.dasc
+++ b/src/vm_x86.dasc
@@ -1720,6 +1720,9 @@ static void build_subroutines(BuildCtx *ctx)
1720 |//-- Base library: catch errors ---------------------------------------- 1720 |//-- Base library: catch errors ----------------------------------------
1721 | 1721 |
1722 |.ffunc_1 pcall 1722 |.ffunc_1 pcall
1723 | mov L:RB, SAVE_L
1724 | lea RA, [BASE+NARGS:RD*8]
1725 | cmp RA, L:RB->maxstack; ja ->fff_fallback
1723 | lea RA, [BASE+8] 1726 | lea RA, [BASE+8]
1724 | sub NARGS:RD, 1 1727 | sub NARGS:RD, 1
1725 | mov PC, 8+FRAME_PCALL 1728 | mov PC, 8+FRAME_PCALL
@@ -1731,6 +1734,9 @@ static void build_subroutines(BuildCtx *ctx)
1731 | jmp ->vm_call_dispatch 1734 | jmp ->vm_call_dispatch
1732 | 1735 |
1733 |.ffunc_2 xpcall 1736 |.ffunc_2 xpcall
1737 | mov L:RB, SAVE_L
1738 | lea RA, [BASE+NARGS:RD*8]
1739 | cmp RA, L:RB->maxstack; ja ->fff_fallback
1734 | cmp dword [BASE+12], LJ_TFUNC; jne ->fff_fallback 1740 | cmp dword [BASE+12], LJ_TFUNC; jne ->fff_fallback
1735 | mov RB, [BASE+4] // Swap function and traceback. 1741 | mov RB, [BASE+4] // Swap function and traceback.
1736 | mov [BASE+12], RB 1742 | mov [BASE+12], RB