From bd962257f1f4aef5240a987c3680210e3232349e Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Fri, 27 Apr 2012 10:15:40 +0200 Subject: [PATCH] Fix for bug 723465 (Make finalize for DOM list bindings use XPConnect). --HG-- extra : rebase_source : e4df7d98765aaa2c600044d69f8714568f1d6109 --- js/xpconnect/crashtests/723465.html | 19 +++++++++++++++++++ js/xpconnect/crashtests/crashtests.list | 1 + js/xpconnect/src/dombindings.cpp | 8 +++++++- js/xpconnect/src/dombindings.h | 8 ++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 js/xpconnect/crashtests/723465.html diff --git a/js/xpconnect/crashtests/723465.html b/js/xpconnect/crashtests/723465.html new file mode 100644 index 000000000000..0f810b963b1d --- /dev/null +++ b/js/xpconnect/crashtests/723465.html @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/js/xpconnect/crashtests/crashtests.list b/js/xpconnect/crashtests/crashtests.list index cd0b5bb2f0a7..a4e977bab19c 100644 --- a/js/xpconnect/crashtests/crashtests.list +++ b/js/xpconnect/crashtests/crashtests.list @@ -35,3 +35,4 @@ load 616930-1.html load 639737-1.html load 648206-1.html load 705875.html +load 723465.html diff --git a/js/xpconnect/src/dombindings.cpp b/js/xpconnect/src/dombindings.cpp index 85a2cb761ea7..421641d84518 100644 --- a/js/xpconnect/src/dombindings.cpp +++ b/js/xpconnect/src/dombindings.cpp @@ -1254,7 +1254,13 @@ ListBase::finalize(JSFreeOp *fop, JSObject *proxy) if (cache) { cache->ClearWrapper(); } - NS_RELEASE(list); + XPCJSRuntime *rt = nsXPConnect::GetRuntimeInstance(); + if (rt) { + rt->DeferredRelease(nativeToSupports(list)); + } + else { + NS_RELEASE(list); + } } diff --git a/js/xpconnect/src/dombindings.h b/js/xpconnect/src/dombindings.h index 643feedfc54b..5933c13e9017 100644 --- a/js/xpconnect/src/dombindings.h +++ b/js/xpconnect/src/dombindings.h @@ -125,6 +125,10 @@ public: *found = false; return true; } + static nsISupports* nativeToSupports(nsISupports* aNative) + { + return aNative; + } }; template @@ -249,6 +253,10 @@ public: static bool nativeGet(JSContext *cx, JSObject *proxy, JSObject *proto, jsid id, bool *found, JS::Value *vp); static ListType *getNative(JSObject *proxy); + static nsISupports* nativeToSupports(ListType* aNative) + { + return Base::nativeToSupports(aNative); + } }; struct nsISupportsResult