mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-12 18:50:08 +00:00
Missing part of fix for bug 117153, fixing threadsafety problems with shared empty buffer handles. b=120300 r=jag sr=alecf a=blizzard
This commit is contained in:
parent
213c1a45d8
commit
362b589445
@ -81,11 +81,15 @@ XPCReadableJSStringWrapper::BufferHandle(JSBool shared) const
|
||||
{
|
||||
if (!mStr) {
|
||||
// This is a "void" string, so return a shared empty buffer handle.
|
||||
static char_type null_char = char_type(0);
|
||||
static shared_buffer_handle_type* sBufferHandle = nsnull;
|
||||
if (!sBufferHandle) {
|
||||
sBufferHandle = NS_AllocateContiguousHandleWithData(sBufferHandle,
|
||||
PRUint32(1), (self_type*)nsnull);
|
||||
sBufferHandle->AcquireReference();
|
||||
sBufferHandle = new nsNonDestructingSharedBufferHandle<char_type>(&null_char, &null_char, 1);
|
||||
sBufferHandle->AcquireReference(); // To avoid the |Destroy|
|
||||
// mechanism unless threads race to
|
||||
// set the refcount, in which case
|
||||
// we'll pull the same trick in
|
||||
// |Destroy|.
|
||||
}
|
||||
return sBufferHandle;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user