Bug 965498 - Don't lose an already_AddRefed<T> and leak blobs in bluetooth. r=qdot, a=1.3+
authorKyle Huey <khuey@kylehuey.com>
Wed, 29 Jan 2014 17:03:51 -0500
changeset 176128 f93e5ee842ed3cc4c6b9c76a540d5eaf9b21ebe0
parent 176127 80924242551d338252d66225f27b7e77fe483264
child 176129 3c330ec8424ceb9eb31158b24000237f29e8de72
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot, 1
bugs965498
milestone28.0a2
Bug 965498 - Don't lose an already_AddRefed<T> and leak blobs in bluetooth. r=qdot, a=1.3+
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());