From 4267bb2f2635bce5aef0c0aa89447dff67e138c2 Mon Sep 17 00:00:00 2001 From: belliash Date: Wed, 5 Jun 2019 07:55:52 +0200 Subject: [PATCH] Execute the 'finally' block when to exception has been thrown. --- engine/vm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/engine/vm.c b/engine/vm.c index 6bcd636..aaaf2b6 100644 --- a/engine/vm.c +++ b/engine/vm.c @@ -3909,7 +3909,15 @@ static sxi32 VmByteCodeExec( ph7_exception **apException; /* Pop the loaded exception */ apException = (ph7_exception **)SySetBasePtr(&pVm->aException); - if(pException == apException[SySetUsed(&pVm->aException) - 1]) { + if(pException && pException == apException[SySetUsed(&pVm->aException) - 1]) { + if(SySetUsed(&pException->sFinally)) { + /* Execute the 'finally' block */ + rc = VmExecFinallyBlock(&(*pVm), pException); + if(rc == SXERR_ABORT) { + /* Abort processing immediately */ + goto Abort; + } + } (void)SySetPop(&pVm->aException); } }