Bug 965498 - Don't lose an already_AddRefed<T> and leak blobs in bluetooth. r=qdot
authorKyle Huey <khuey@kylehuey.com>
Wed, 29 Jan 2014 17:03:51 -0500
changeset 165935 464a1e7fb0d96a29e8486902fca71aaf876049a4
parent 165934 1d4c70a7296ede71f9adeee8291af9c50625f285
child 165936 6b1f0c0319b1c338355d46bd62510774954c3e27
push id26107
push usercbook@mozilla.com
push dateThu, 30 Jan 2014 09:59:38 +0000
treeherdermozilla-central@25c361f6661f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs965498
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 965498 - Don't lose an already_AddRefed<T> and leak blobs in bluetooth. r=qdot
dom/bluetooth/bluedroid/BluetoothOppManager.cpp
dom/bluetooth/bluez/BluetoothOppManager.cpp
--- a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp
@@ -57,17 +57,18 @@ StaticRefPtr<BluetoothOppManager> sBluet
 static bool sInShutdown = false;
 }
 
 class mozilla::dom::bluetooth::SendFileBatch {
 public:
   SendFileBatch(const nsAString& aDeviceAddress, BlobParent* aActor)
     : mDeviceAddress(aDeviceAddress)
   {
-    mBlobs.AppendElement(aActor->GetBlob().get());
+    nsCOMPtr<nsIDOMBlob> blob = aActor->GetBlob();
+    mBlobs.AppendElement(blob);
   }
 
   nsString mDeviceAddress;
   nsCOMArray<nsIDOMBlob> mBlobs;
 };
 
 NS_IMETHODIMP
 BluetoothOppManager::Observe(nsISupports* aSubject,
@@ -369,17 +370,18 @@ BluetoothOppManager::AppendBlobToSend(co
    * - mBatches is empty, or
    * - aDeviceAddress differs from mDeviceAddress of the last batch
    */
   if (mBatches.IsEmpty() ||
       aDeviceAddress != mBatches[indexTail].mDeviceAddress) {
     SendFileBatch batch(aDeviceAddress, aActor);
     mBatches.AppendElement(batch);
   } else {
-    mBatches[indexTail].mBlobs.AppendElement(aActor->GetBlob().get());
+    nsCOMPtr<nsIDOMBlob> blob = aActor->GetBlob();
+    mBatches[indexTail].mBlobs.AppendElement(blob);
   }
 }
 
 void
 BluetoothOppManager::DiscardBlobsToSend()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
--- a/dom/bluetooth/bluez/BluetoothOppManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothOppManager.cpp
@@ -57,17 +57,18 @@ StaticRefPtr<BluetoothOppManager> sBluet
 static bool sInShutdown = false;
 }
 
 class mozilla::dom::bluetooth::SendFileBatch {
 public:
   SendFileBatch(const nsAString& aDeviceAddress, BlobParent* aActor)
     : mDeviceAddress(aDeviceAddress)
   {
-    mBlobs.AppendElement(aActor->GetBlob().get());
+    nsCOMPtr<nsIDOMBlob> blob = aActor->GetBlob();
+    mBlobs.AppendElement(blob);
   }
 
   nsString mDeviceAddress;
   nsCOMArray<nsIDOMBlob> mBlobs;
 };
 
 NS_IMETHODIMP
 BluetoothOppManager::Observe(nsISupports* aSubject,
@@ -385,17 +386,18 @@ BluetoothOppManager::AppendBlobToSend(co
    * - mBatches is empty, or
    * - aDeviceAddress differs from mDeviceAddress of the last batch
    */
   if (mBatches.IsEmpty() ||
       aDeviceAddress != mBatches[indexTail].mDeviceAddress) {
     SendFileBatch batch(aDeviceAddress, aActor);
     mBatches.AppendElement(batch);
   } else {
-    mBatches[indexTail].mBlobs.AppendElement(aActor->GetBlob().get());
+    nsCOMPtr<nsIDOMBlob> blob = aActor->GetBlob();
+    mBatches[indexTail].mBlobs.AppendElement(blob);
   }
 }
 
 void
 BluetoothOppManager::DiscardBlobsToSend()
 {
   MOZ_ASSERT(NS_IsMainThread());