Bug 1132528 - Handle non existent key. r=nical, a=bajaj
authorSotaro Ikeda <sikeda@mozilla.com>
Tue, 03 Mar 2015 06:36:48 -0800
changeset 237564 0dbec8381c00fc1c2b754d9c08e984cf3b62b6d0
parent 237563 2df322a91b53a68d1cc53d1e8c52bd55e870b848
child 237565 30a9e827a04e3dc30bf8cfb3707d28f15d978d8f
push id301
push userryanvm@gmail.com
push dateWed, 11 Mar 2015 02:14:36 +0000
treeherdermozilla-b2g37_v2_2@004fa1cb1dd4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical, bajaj
bugs1132528
milestone37.0
Bug 1132528 - Handle non existent key. r=nical, a=bajaj
gfx/layers/ipc/SharedBufferManagerParent.cpp
--- a/gfx/layers/ipc/SharedBufferManagerParent.cpp
+++ b/gfx/layers/ipc/SharedBufferManagerParent.cpp
@@ -48,16 +48,20 @@ public:
   {
     if (SharedBufferManagerParent::sManagerMonitor) {
       SharedBufferManagerParent::sManagerMonitor->Lock();
     }
     map<base::ProcessId, SharedBufferManagerParent*>::iterator it;
     for (it = SharedBufferManagerParent::sManagers.begin(); it != SharedBufferManagerParent::sManagers.end(); it++) {
       base::ProcessId pid = it->first;
       SharedBufferManagerParent *mgr = it->second;
+      if (!mgr) {
+        printf_stderr("GrallocReporter::CollectReports() mgr is nullptr");
+        continue;
+      }
 
       nsAutoCString pidName;
       LinuxUtils::GetThreadName(pid, pidName);
 
       MutexAutoLock lock(mgr->mLock);
       std::map<int64_t, android::sp<android::GraphicBuffer> >::iterator buf_it;
       for (buf_it = mgr->mBuffers.begin(); buf_it != mgr->mBuffers.end(); buf_it++) {
         nsresult rv;
@@ -327,17 +331,21 @@ void SharedBufferManagerParent::DropGral
 MessageLoop* SharedBufferManagerParent::GetMessageLoop()
 {
   return mThread->message_loop();
 }
 
 SharedBufferManagerParent* SharedBufferManagerParent::GetInstance(ProcessId id)
 {
   NS_ASSERTION(sManagers.count(id) == 1, "No BufferManager for the process");
-  return sManagers[id];
+  if (sManagers.count(id) == 1) {
+    return sManagers[id];
+  } else {
+    return nullptr;
+  }
 }
 
 #ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
 android::sp<android::GraphicBuffer>
 SharedBufferManagerParent::GetGraphicBuffer(int64_t key)
 {
   MutexAutoLock lock(mLock);
   if (mBuffers.count(key) == 1) {