Bug 814341 - Fix memory leak in Bluetooth. r=gyeh, a=blocking-basecamp
authorEric Chou <echou@mozilla.com>
Thu, 13 Dec 2012 20:12:04 +0800
changeset 118877 2af0ee41e9daf77de9530ff195567d05a152f236
parent 118876 5d10c266fa868749b43224f977edcf5dfdc7b006
child 118878 0047c670657bb73351fa1623d3f4e14b2da99df7
push idunknown
push userunknown
push dateunknown
reviewersgyeh, blocking-basecamp
bugs814341
milestone19.0a2
Bug 814341 - Fix memory leak in Bluetooth. r=gyeh, a=blocking-basecamp
dom/bluetooth/BluetoothOppManager.h
dom/bluetooth/ObexBase.cpp
dom/bluetooth/ObexBase.h
--- a/dom/bluetooth/BluetoothOppManager.h
+++ b/dom/bluetooth/BluetoothOppManager.h
@@ -152,18 +152,18 @@ private:
   bool mTransferMode;
 
   /**
    * Set when receiving the first PUT packet and wait for
    * ConfirmReceivingFile() to be called.
    */
   bool mWaitingForConfirmationFlag;
 
-  nsAutoPtr<uint8_t> mBodySegment;
-  nsAutoPtr<uint8_t> mReceivedDataBuffer;
+  nsAutoArrayPtr<uint8_t> mBodySegment;
+  nsAutoArrayPtr<uint8_t> mReceivedDataBuffer;
 
   nsCOMPtr<nsIDOMBlob> mBlob;
   nsCOMPtr<nsIThread> mReadFileThread;
   nsCOMPtr<nsIOutputStream> mOutputStream;
   nsCOMPtr<nsIInputStream> mInputStream;
 
   nsRefPtr<BluetoothReplyRunnable> mRunnable;
   nsRefPtr<DeviceStorageFile> mDsFile;
--- a/dom/bluetooth/ObexBase.cpp
+++ b/dom/bluetooth/ObexBase.cpp
@@ -113,14 +113,15 @@ ParseHeaders(const uint8_t* aHeaderStart
         // 4 byte quantity
         contentLength = 4;
         break;
     }
 
     uint8_t* content = new uint8_t[contentLength];
     memcpy(content, ptr, contentLength);
     aRetHandlerSet->AddHeader(new ObexHeader(headerId, contentLength, content));
+    delete [] content;
 
     ptr += contentLength;
   }
 }
 
 END_BLUETOOTH_NAMESPACE
--- a/dom/bluetooth/ObexBase.h
+++ b/dom/bluetooth/ObexBase.h
@@ -114,17 +114,17 @@ public:
   }
 
   ~ObexHeader()
   {
   }
 
   ObexHeaderId mId;
   int mDataLength;
-  nsAutoPtr<uint8_t> mData;
+  nsAutoArrayPtr<uint8_t> mData;
 };
 
 class ObexHeaderSet {
 public:
   uint8_t mOpcode;
   nsTArray<nsAutoPtr<ObexHeader> > mHeaders;
 
   ObexHeaderSet(uint8_t aOpcode) : mOpcode(aOpcode)