Bug 815542 - crash in IncrementalCollectSlice r=billm

--HG--
extra : rebase_source : d751b3684f6461b094278aa39508417928c2b660
This commit is contained in:
Jon Coppeard 2013-01-25 09:56:04 +00:00
parent 07b4d84cc4
commit 6ecb789968
3 changed files with 14 additions and 5 deletions

View File

@ -830,6 +830,8 @@ XPCJSRuntime::FinalizeCallback(JSFreeOp *fop, JSFinalizeStatus status, JSBool is
// Find dying scopes.
XPCWrappedNativeScope::StartFinalizationPhaseOfGC(fop, self);
XPCStringConvert::ClearCache();
self->mDoingFinalization = true;
break;
}

View File

@ -29,20 +29,25 @@
static nsStringBuffer* sCachedBuffer = nullptr;
static JSString* sCachedString = nullptr;
// Called from GC finalize callback to make sure we don't hand out a pointer to
// a JSString that's about to be finalized by incremental sweeping.
// static
void
XPCStringConvert::ClearCache()
{
sCachedBuffer = nullptr;
sCachedString = nullptr;
}
static void
FinalizeDOMString(const JSStringFinalizer *fin, jschar *chars)
{
nsStringBuffer* buf = nsStringBuffer::FromData(chars);
if (buf == sCachedBuffer) {
sCachedBuffer = nullptr;
// No need to clear sCachedString
}
buf->Release();
}
static const JSStringFinalizer sDOMStringFinalizer = { FinalizeDOMString };
// convert a readable to a JSString, copying string data
// static
jsval

View File

@ -3437,6 +3437,8 @@ public:
static jsval ReadableToJSVal(JSContext *cx, const nsAString &readable,
nsStringBuffer** sharedBuffer);
static void ClearCache();
private:
XPCStringConvert(); // not implemented
};