Bug 1118031: Fix toolhelp32 snapshot leak in PluginModuleParent; r=jimm
authorAaron Klotz <aklotz@mozilla.com>
Mon, 05 Jan 2015 16:39:38 -0700
changeset 222085 e9535d758389f7d75043a1665d3ebce4cf9145fa
parent 222084 7cdfef0fddb8da371663df0756119fdf1b8e6387
child 222086 425de18940f3929fbec345b94cff490f9f37dac6
push id53528
push useraklotz@mozilla.com
push dateTue, 06 Jan 2015 00:15:31 +0000
treeherdermozilla-inbound@e9535d758389 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1118031
milestone37.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 1118031: Fix toolhelp32 snapshot leak in PluginModuleParent; r=jimm
dom/plugins/ipc/PluginModuleParent.cpp
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -30,18 +30,19 @@
 #include "nsIObserverService.h"
 #include "nsNPAPIPlugin.h"
 #include "nsPrintfCString.h"
 #include "prsystem.h"
 #include "GeckoProfiler.h"
 #include "nsPluginTags.h"
 
 #ifdef XP_WIN
+#include "mozilla/widget/AudioSession.h"
+#include "nsWindowsHelpers.h"
 #include "PluginHangUIParent.h"
-#include "mozilla/widget/AudioSession.h"
 #endif
 
 #ifdef MOZ_ENABLE_PROFILER_SPS
 #include "nsIProfiler.h"
 #include "nsIProfileSaveEvent.h"
 #endif
 
 #ifdef MOZ_WIDGET_GTK
@@ -2476,17 +2477,17 @@ PluginModuleChromeParent::InitializeInje
     if (kNotFound == lastSlash)
         return;
 
     if (!StringBeginsWith(Substring(path, lastSlash + 1),
                           NS_LITERAL_CSTRING(FLASH_PLUGIN_PREFIX)))
         return;
 
     TimeStamp th32Start = TimeStamp::Now();
-    HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+    nsAutoHandle snapshot(CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0));
     if (INVALID_HANDLE_VALUE == snapshot)
         return;
     TimeStamp th32End = TimeStamp::Now();
     mTimeBlocked += (th32End - th32Start);
 
     DWORD pluginProcessPID = GetProcessId(Process()->GetChildProcessHandle());
     mFlashProcess1 = GetFlashChildOfPID(pluginProcessPID, snapshot);
     if (mFlashProcess1) {