Bug 1418448 part 2: AccessibleHandler: Clean up DynamicIA2Data. r=aklotz
authorJames Teh <jteh@mozilla.com>
Fri, 24 Nov 2017 15:14:04 +1000
changeset 394019 57aa3370993fb4f1fca77ebd535ae189abe75363
parent 394018 3f52f6885fc5c9422d402664965ff317069bf58f
child 394020 79bf386e2fb3640330ecbdf34d122e021f8c25d7
push id32989
push userdluca@mozilla.com
push dateWed, 29 Nov 2017 10:09:52 +0000
treeherdermozilla-central@40b464eb6b31 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaklotz
bugs1418448
milestone59.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 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
@@ -11,16 +11,17 @@
 #define INITGUID
 
 #include "AccessibleHandler.h"
 #include "AccessibleHandlerControl.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"
@@ -87,16 +88,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();
   }
   ClearTextCache();
 }
 
 HRESULT
 AccessibleHandler::ResolveIA2()
@@ -388,16 +391,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.