Bug 1124973 (part 4) - Remove erroneous uses of PL_DHASH_ENTRY_IS_{BUSY,FREE} in nsJSNPRuntime.cpp. r=froydnj.
The BUSY check is merely useless, because BUSY is always true for a non-null
entry returned by PL_DHashTableAdd.
The FREE check is downright dangerous because it dereferences |entry| and
PL_DHashTableAdd() returns nullptr on OOM. A null check makes more sense here.
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -1884,17 +1884,17 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JS
if (!entry) {
// Out of memory
JS_ReportOutOfMemory(cx);
return nullptr;
}
- if (PL_DHASH_ENTRY_IS_BUSY(entry) && entry->mJSObj) {
+ if (entry->mJSObj) {
// Found a live NPObject wrapper. It may not be in the same compartment
// as cx, so we need to wrap it before returning it.
JS::Rooted<JSObject*> obj(cx, entry->mJSObj);
if (!JS_WrapObject(cx, &obj)) {
return nullptr;
}
return obj;
}
@@ -2041,17 +2041,17 @@ LookupNPP(NPObject *npobj)
if (npobj->_class == &nsJSObjWrapper::sJSObjWrapperNPClass) {
nsJSObjWrapper* o = static_cast<nsJSObjWrapper*>(npobj);
return o->mNpp;
}
NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
(PL_DHashTableAdd(&sNPObjWrappers, npobj));
- if (PL_DHASH_ENTRY_IS_FREE(entry)) {
+ if (!entry) {
return nullptr;
}
NS_ASSERTION(entry->mNpp, "Live NPObject entry w/o an NPP!");
return entry->mNpp;
}