summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2012-12-08 02:08:17 +0100
committerportix <portix@gmx.net>2012-12-08 02:08:17 +0100
commit89e9043503133bc4a89cc169bf328bc6732eb330 (patch)
tree3d119eec15a4695e3e039c0500aeb3e3efaae41e /src
parente546c944645580065fd7b8df7f2e048f11d26311 (diff)
downloaddwb-89e9043503133bc4a89cc169bf328bc6732eb330.zip
Destroy current deferred before chaining further
Diffstat (limited to 'src')
-rw-r--r--src/scripts.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/scripts.c b/src/scripts.c
index 4da0aed1..d2db539e 100644
--- a/src/scripts.c
+++ b/src/scripts.c
@@ -1443,19 +1443,20 @@ deferred_resolve(JSContextRef ctx, JSObjectRef f, JSObjectRef this, size_t argc,
if (priv->resolve)
ret = JSObjectCallAsFunction(ctx, priv->resolve, NULL, argc, argv, exc);
- if (priv->next)
+ JSObjectRef next = priv->next;
+ deferred_destroy(ctx, this, priv);
+
+ if (next)
{
if ( ret && JSValueIsObjectOfClass(ctx, ret, s_deferred_class) )
{
JSObjectRef o = JSValueToObject(ctx, ret, NULL);
- deferred_transition(ctx, priv->next, o)->reject = NULL;
- priv->next = o;
+ deferred_transition(ctx, next, o)->reject = NULL;
}
else
- deferred_resolve(ctx, f, priv->next, argc, argv, exc);
+ deferred_resolve(ctx, f, next, argc, argv, exc);
}
- deferred_destroy(ctx, this, priv);
return UNDEFINED;
}
@@ -1471,18 +1472,19 @@ deferred_reject(JSContextRef ctx, JSObjectRef f, JSObjectRef this, size_t argc,
if (priv->reject)
ret = JSObjectCallAsFunction(ctx, priv->reject, NULL, argc, argv, exc);
- if (priv->next)
+ JSObjectRef next = priv->next;
+ deferred_destroy(ctx, this, priv);
+
+ if (next)
{
if ( ret && JSValueIsObjectOfClass(ctx, ret, s_deferred_class) )
{
JSObjectRef o = JSValueToObject(ctx, ret, NULL);
- deferred_transition(ctx, priv->next, o)->resolve = NULL;
- priv->next = o;
+ deferred_transition(ctx, next, o)->resolve = NULL;
}
else
- deferred_reject(ctx, f, priv->next, argc, argv, exc);
+ deferred_reject(ctx, f, next, argc, argv, exc);
}
- deferred_destroy(ctx, this, priv);
return UNDEFINED;
}