From a5abfe834e9e16144d7d0a3d48fef2eb82c777c6 Mon Sep 17 00:00:00 2001 From: David Major Date: Thu, 12 Feb 2015 10:33:45 +1300 Subject: [PATCH] Bug 1131871 - auto_com should only uninitialize when successful. r=padenot --HG-- extra : rebase_source : 4af27a3e50b68ad1ee4d869b1a3bee3eeb4a1141 --- media/libcubeb/src/cubeb_wasapi.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/media/libcubeb/src/cubeb_wasapi.cpp b/media/libcubeb/src/cubeb_wasapi.cpp index 2b744456709..4e222f7dae0 100644 --- a/media/libcubeb/src/cubeb_wasapi.cpp +++ b/media/libcubeb/src/cubeb_wasapi.cpp @@ -164,7 +164,7 @@ private: struct auto_com { auto_com() - : need_uninit(true) { + : need_uninit(false) { HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); // This is for information purposes only, in anycase, COM is initialized // at the end of the constructor. @@ -172,14 +172,15 @@ struct auto_com { // This is an error, COM was not initialized by this function, so it is // not necessary to uninit it. LOG("COM already initialized in STA."); - need_uninit = false; } else if (hr == S_FALSE) { // This is not an error. We are allowed to call CoInitializeEx more than // once, as long as it is matches by an CoUninitialize call. // We do that in the dtor which is guaranteed to be called. LOG("COM already initialized in MTA"); + need_uninit = true; } else if (hr == S_OK) { LOG("COM initialized."); + need_uninit = true; } } ~auto_com() {