Bug 1440564: mscom::StructToStream: Free the buffer when destroying the instance. r?aklotz draft
authorJames Teh <jteh@mozilla.com>
Fri, 23 Feb 2018 20:00:30 +1000
changeset 758928 47b01e552d0f785975584d87f929cc5f2f04b3d8
parent 758927 6661c077325c35af028f1cdaa660f673cbea39be
push id100221
push userbmo:jteh@mozilla.com
push dateFri, 23 Feb 2018 10:08:30 +0000
reviewersaklotz
bugs1440564
milestone60.0a1
Bug 1440564: mscom::StructToStream: Free the buffer when destroying the instance. r?aklotz You'd think that MesHandleFree would free the buffer, since it was created by RPC, but it doesn't. Therefore, we must free it ourselves using midl_user_free. MozReview-Commit-ID: 9KzWTngFEEq
ipc/mscom/StructStream.h
--- a/ipc/mscom/StructStream.h
+++ b/ipc/mscom/StructStream.h
@@ -71,16 +71,21 @@ public:
     }
   }
 
   ~StructToStream()
   {
     if (mHandle) {
       ::MesHandleFree(mHandle);
     }
+    if (mBuffer) {
+      // Bug 1440564: You'd think that MesHandleFree would free the buffer,
+      // since it was created by RPC, but it doesn't.
+      midl_user_free(mBuffer);
+    }
   }
 
   static unsigned long GetEmptySize()
   {
     return sizeof(detail::EncodedLenT);
   }
 
   static HRESULT WriteEmpty(IStream* aDestStream)