Bug 1418448 part 2: AccessibleHandler: Clean up DynamicIA2Data. r?aklotz draft
authorJames Teh <jteh@mozilla.com>
Fri, 24 Nov 2017 15:14:04 +1000
changeset 702985 a0147b807e921064cd78a32ff868c90098e55fcd
parent 702984 f53857ce9acae929939979deb8f2a503a6f25afd
child 702986 e4b62d5a39d00a3f26f62a7c35d2a64ed740c55c
child 704794 8ab8603daa264735093616c93ba861840dee32c5
push id90653
push userbmo:jteh@mozilla.com
push dateFri, 24 Nov 2017 05:33:22 +0000
reviewersaklotz
bugs1418448
milestone59.0a1
Bug 1418448 part 2: AccessibleHandler: Clean up DynamicIA2Data. r?aklotz We need to clean up the VARIANT and BSTRs in DynamicIA2Data in the handler as well. We do this in two places: 1. Before reading a new payload (because we need to clean up the existing payload); and 2. When we're being destroyed. MozReview-Commit-ID: GvO7csuxtwZ
accessible/ipc/win/handler/AccessibleHandler.cpp
--- a/accessible/ipc/win/handler/AccessibleHandler.cpp
+++ b/accessible/ipc/win/handler/AccessibleHandler.cpp
@@ -12,16 +12,17 @@
 
 #include "AccessibleHandler.h"
 #include "AccessibleHandlerControl.h"
 #include "AccessibleTextTearoff.h"
 
 #include "Factory.h"
 #include "HandlerData.h"
 #include "mozilla/ArrayUtils.h"
+#include "mozilla/a11y/HandlerDataCleanup.h"
 #include "mozilla/mscom/Registration.h"
 #include "mozilla/UniquePtr.h"
 
 #include <objbase.h>
 #include <uiautomation.h>
 #include <winreg.h>
 
 #include "AccessibleHypertext.h"
@@ -80,16 +81,18 @@ AccessibleHandler::AccessibleHandler(IUn
     return;
   }
 
   mCacheGen = ctl->GetCacheGen();
 }
 
 AccessibleHandler::~AccessibleHandler()
 {
+  // No need to zero memory, since we're being destroyed anyway.
+  CleanupDynamicIA2Data(mCachedData.mDynamicData, false);
   if (mCachedData.mGeckoBackChannel) {
     mCachedData.mGeckoBackChannel->Release();
   }
 }
 
 HRESULT
 AccessibleHandler::ResolveIA2()
 {
@@ -314,16 +317,19 @@ AccessibleHandler::ReadHandlerPayload(IS
   // interfaces are available. Therefore, deserialize into a temporary struct
   // and update mCachedData only after deserialization completes.
   // The decoding functions can misbehave if their target memory is not zeroed
   // beforehand, so ensure we do that.
   IA2Payload newData{};
   if (!deserializer.Read(&newData, &IA2Payload_Decode)) {
     return E_FAIL;
   }
+  // Clean up the old data.
+  // No need to zero memory, since we're about to completely replace this.
+  CleanupDynamicIA2Data(mCachedData.mDynamicData, false);
   mCachedData = newData;
 
   // These interfaces have been aggregated into the proxy manager.
   // The proxy manager will resolve these interfaces now on QI,
   // so we can release these pointers.
   // However, we don't null them out because we use their presence
   // to determine whether the interface is available
   // so as to avoid pointless cross-proc QI calls returning E_NOINTERFACE.