From 4ad7388f6204180f983960593b7f885980517ca9 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 8 Jan 2014 22:54:06 -0800 Subject: [PATCH] If I call ExecuteStart I /must/ call ExecuteEnd. --- Execute.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Execute.cpp b/Execute.cpp index 87e7de2..139aada 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -1293,7 +1293,7 @@ JSObjectRef CYGetGlobalObject(JSContextRef context) { const char *CYExecute(CYPool &pool, CYUTF8String code) { JSContextRef context(CYGetJSContext()); - JSValueRef exception(NULL), result; + JSValueRef exception(NULL); void *handle; if (hooks_ != NULL && hooks_->ExecuteStart != NULL) @@ -1301,8 +1301,9 @@ const char *CYExecute(CYPool &pool, CYUTF8String code) { else handle = NULL; - const char *json; + try { + JSValueRef result; try { result = JSEvaluateScript(context, CYJSString(code), NULL, NULL, 0, &exception); } catch (const char *error) { @@ -1315,6 +1316,7 @@ const char *CYExecute(CYPool &pool, CYUTF8String code) { if (JSValueIsUndefined(context, result)) return NULL; + const char *json; try { json = CYPoolCCYON(pool, context, result, &exception); } catch (const char *error) { @@ -1326,9 +1328,13 @@ const char *CYExecute(CYPool &pool, CYUTF8String code) { CYSetProperty(context, CYGetGlobalObject(context), Result_, result); - if (hooks_ != NULL && hooks_->ExecuteEnd != NULL) - (*hooks_->ExecuteEnd)(context, handle); return json; + + } catch (...) { + if (hooks_ != NULL && hooks_->ExecuteEnd != NULL) + (*hooks_->ExecuteEnd)(context, handle); + throw; + } } extern "C" void CydgetSetupContext(JSGlobalContextRef context) { -- 2.49.0