Bug 1124973 (part 4) - Remove erroneous uses of PL_DHASH_ENTRY_IS_{BUSY,FREE} in nsJSNPRuntime.cpp. r=froydnj.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 26 Jan 2015 14:05:06 -0800
changeset 239566 fc7c269f2b7a7f2a9b55554c6961ccd156b475cf
parent 239565 ec10af0d21816723e3fbae6949dd2f12eb1e3092
child 239567 332e69cd3273c05f1c75cb85d37d80dc3f69f1ce
push id500
push userjoshua.m.grant@gmail.com
push dateThu, 29 Jan 2015 01:48:36 +0000
reviewersfroydnj
bugs1124973
milestone38.0a1
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.
dom/plugins/base/nsJSNPRuntime.cpp
--- 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;
 }