Index: base/threading/platform_thread_win.cc |
diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc |
index 25973bcada928651091da0fa7025356f34604602..dc36a140447a68523fd1f58be0aef64715fae33c 100644 |
--- a/base/threading/platform_thread_win.cc |
+++ b/base/threading/platform_thread_win.cc |
@@ -114,17 +114,15 @@ bool CreateThreadInternal(size_t stack_size, |
// have to work running on CreateThread() threads anyway, since we run code |
// on the Windows thread pool, etc. For some background on the difference: |
// http://www.microsoft.com/msj/1099/win32/win321099.aspx |
- void* thread_handle = |
- ::CreateThread(nullptr, stack_size, ThreadFunc, params, flags, nullptr); |
- if (!thread_handle) { |
+ base::win::ScopedHandle thread_handle( |
+ ::CreateThread(nullptr, stack_size, ThreadFunc, params, flags, nullptr)); |
+ if (!thread_handle.IsValid()) { |
delete params; |
return false; |
} |
if (out_thread_handle) |
- *out_thread_handle = PlatformThreadHandle(thread_handle); |
- else |
- CloseHandle(thread_handle); |
+ *out_thread_handle = PlatformThreadHandle(thread_handle.Take()); |
return true; |
} |