codec/h264: fix potential segfault and mf_init

This commit is contained in:
Norbert Federa 2017-10-17 19:28:54 +02:00
parent acd97ccdd7
commit 456ce96618
2 changed files with 6 additions and 4 deletions

View File

@ -468,7 +468,7 @@ BOOL h264_context_init(H264_CONTEXT* h264)
for (i = 0; i < MAX_SUBSYSTEMS; i++)
{
H264_CONTEXT_SUBSYSTEM* subsystem = subSystems[i];
if (!subsystem->Init)
if (!subsystem || !subsystem->Init)
break;
if (subsystem->Init(h264))

View File

@ -517,10 +517,12 @@ static BOOL mf_init(H264_CONTEXT* h264)
"MFCreateMediaType");
sys->MFCreateDXGIDeviceManager = (pfnMFCreateDXGIDeviceManager) GetProcAddress(
sys->mfplat, "MFCreateDXGIDeviceManager");
/**
* Note: MFCreateDXGIDeviceManager is supported starting from Windows 8.
* Don't fail below if GetProcAddress returned NULL.
*/
if (!sys->MFStartup || !sys->MFShutdown || !sys->MFCreateSample
|| !sys->MFCreateMemoryBuffer ||
!sys->MFCreateMediaType || !sys->MFCreateDXGIDeviceManager)
|| !sys->MFCreateMemoryBuffer || !sys->MFCreateMediaType)
goto error;
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);