Bug 858900 - Poison JSContext. r=luke
--- a/js/public/Utility.h
+++ b/js/public/Utility.h
@@ -503,16 +503,27 @@ static JS_ALWAYS_INLINE void
js_delete(T *p)
{
if (p) {
p->~T();
js_free(p);
}
}
+template<class T>
+static JS_ALWAYS_INLINE void
+js_delete_poison(T *p)
+{
+ if (p) {
+ p->~T();
+ memset(p, 0x3B, sizeof(T));
+ js_free(p);
+ }
+}
+
template <class T>
static JS_ALWAYS_INLINE T *
js_pod_malloc()
{
return (T *)js_malloc(sizeof(T));
}
template <class T>
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -426,17 +426,17 @@ js::DestroyContext(JSContext *cx, Destro
JS::PrepareForFullGC(rt);
GC(rt, GC_NORMAL, JS::gcreason::LAST_CONTEXT);
} else if (mode == DCM_FORCE_GC) {
JS_ASSERT(!rt->isHeapBusy());
JS::PrepareForFullGC(rt);
GC(rt, GC_NORMAL, JS::gcreason::DESTROY_CONTEXT);
}
- js_delete(cx);
+ js_delete_poison(cx);
}
bool
AutoResolving::alreadyStartedSlow() const
{
JS_ASSERT(link);
AutoResolving *cursor = link;
do {