Bug 1901554 p1: Call CoTaskMemFree directly from combase.dll for MFTEncoder. r=padenot

This prevents us from having to preload ole32.dll and all of its associated
dependencies.

Differential Revision: https://phabricator.services.mozilla.com/D213256
This commit is contained in:
Bob Owen 2024-06-14 10:39:55 +00:00
parent 59b0794780
commit caa2cde4ba
3 changed files with 15 additions and 2 deletions

View File

@ -8,6 +8,7 @@
#include "mozilla/Logging.h"
#include "mozilla/WindowsProcessMitigations.h"
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/mscom/COMWrappers.h"
#include "mozilla/mscom/Utils.h"
#include "WMFUtils.h"
#include <comdef.h>
@ -166,7 +167,7 @@ static void PopulateEncoderInfo(const GUID& aSubtype,
activates[i]->Release();
activates[i] = nullptr;
}
CoTaskMemFree(activates);
mscom::wrapped::CoTaskMemFree(activates);
}
Maybe<MFTEncoder::Info> MFTEncoder::GetInfo(const GUID& aSubtype) {
@ -221,7 +222,7 @@ already_AddRefed<IMFActivate> MFTEncoder::CreateFactory(const GUID& aSubtype) {
activates[i]->Release();
activates[i] = nullptr;
}
CoTaskMemFree(activates);
mscom::wrapped::CoTaskMemFree(activates);
return factory.forget();
}

View File

@ -98,4 +98,14 @@ HRESULT CoCreateGuid(GUID* pguid) {
return pCoCreateGuid(pguid);
}
void CoTaskMemFree(LPVOID pv) {
static const StaticDynamicallyLinkedFunctionPtr<decltype(&::CoTaskMemFree)>
pCoTaskMemFree(L"combase.dll", "CoTaskMemFree");
if (!pCoTaskMemFree) {
return ::CoTaskMemFree(pv);
}
return pCoTaskMemFree(pv);
}
} // namespace mozilla::mscom::wrapped

View File

@ -33,6 +33,8 @@ HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter,
HRESULT CoCreateGuid(GUID* pguid);
void CoTaskMemFree(LPVOID pv);
} // namespace mozilla::mscom::wrapped
#endif // mozilla_mscom_COMWrappers_h