Bug 1102223 - Wrapping |aWrappedParameters| before checking for shutdown to prevent memory leaks; r=Dexter,Yoric
authorNihar Mehta <niharmehta79@gmail.com>
Thu, 11 Dec 2014 03:45:01 +0530
changeset 219144 477d76b9d58d93cdbb183e76eee52c936ee4d53c
parent 219143 56ba684600e15eb9d47945cce8d2180df1d5448f
child 219145 a8f9ed3d7554f4eb51cf6f0f6295f00dc22bc6a1
push id27956
push userkwierso@gmail.com
push dateFri, 12 Dec 2014 00:47:19 +0000
treeherdermozilla-central@32a2c5bd2f68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersDexter, Yoric
bugs1102223
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 1102223 - Wrapping |aWrappedParameters| before checking for shutdown to prevent memory leaks; r=Dexter,Yoric
toolkit/components/filewatcher/NativeFileWatcherWin.cpp
--- a/toolkit/components/filewatcher/NativeFileWatcherWin.cpp
+++ b/toolkit/components/filewatcher/NativeFileWatcherWin.cpp
@@ -560,24 +560,24 @@ NativeFileWatcherIOTask::Run()
  *         otherwise NS_OK.
  */
 nsresult
 NativeFileWatcherIOTask::AddPathRunnableMethod(
   PathRunnablesParametersWrapper* aWrappedParameters)
 {
   MOZ_ASSERT(!NS_IsMainThread());
 
+  nsAutoPtr<PathRunnablesParametersWrapper> wrappedParameters(aWrappedParameters);
+
   // We return immediately if |mShuttingDown| is true (see below for
   // details about the shutdown protocol being followed).
   if (mShuttingDown) {
     return NS_OK;
   }
 
-  nsAutoPtr<PathRunnablesParametersWrapper> wrappedParameters(aWrappedParameters);
-
   if (!wrappedParameters ||
       !wrappedParameters->mChangeCallbackHandle) {
     FILEWATCHERLOG("NativeFileWatcherIOTask::AddPathRunnableMethod - Invalid arguments.");
     return NS_ERROR_NULL_POINTER;
   }
 
   // Is aPathToWatch already being watched?
   WatchedResourceDescriptor* watchedResource =
@@ -730,24 +730,24 @@ NativeFileWatcherIOTask::AddPathRunnable
  *        handles.
  */
 nsresult
 NativeFileWatcherIOTask::RemovePathRunnableMethod(
   PathRunnablesParametersWrapper* aWrappedParameters)
 {
   MOZ_ASSERT(!NS_IsMainThread());
 
+  nsAutoPtr<PathRunnablesParametersWrapper> wrappedParameters(aWrappedParameters);
+
   // We return immediately if |mShuttingDown| is true (see below for
   // details about the shutdown protocol being followed).
   if (mShuttingDown) {
     return NS_OK;
   }
 
-  nsAutoPtr<PathRunnablesParametersWrapper> wrappedParameters(aWrappedParameters);
-
   if (!wrappedParameters ||
       !wrappedParameters->mChangeCallbackHandle) {
     return NS_ERROR_NULL_POINTER;
   }
 
   WatchedResourceDescriptor* toRemove =
     mWatchedResourcesByPath.Get(wrappedParameters->mPath);
   if (!toRemove) {