If we want to determine memory allocation result,we should use 'new(std::nothrow)' instead of new,because 'new' failed will throw 'std::bad_alloc' exception. It may cause potential exception since modified code path does not have any try catch.
The original code can cause resource leak if just return 'MFX_ERR_MEMORY_ALLOC', see libvpl/src/mfx_dispatcher_vpl_loader.cpp:line 211,276
Solution
Use 'new(std::nothrow)' instead of 'new'
Free resouce before return 'MFX_ERR_MEMORY_ALLOC'
How Tested
libvpl/src/mfx_dispatcher_vpl_loader.cpp:line 211,276
1.1 set *'LibInfo libInfo = nullptr' (If no memory,new (std::nothrow) will return nullptr)
1.2 run vpl-timing with argument '-e' ( run 'MFXEnumImplementations '** function)
1.3 MFXEnumImplementations return 'MFX_ERR_NOT_FOUND',No memory leak,No crash,it is what we desired
Issue
If we want to determine memory allocation result,we should use 'new(std::nothrow)' instead of new,because 'new' failed will throw 'std::bad_alloc' exception. It may cause potential exception since modified code path does not have any try catch.
The original code can cause resource leak if just return 'MFX_ERR_MEMORY_ALLOC', see libvpl/src/mfx_dispatcher_vpl_loader.cpp:line 211,276
Solution
How Tested
libvpl/src/mfx_dispatcher_vpl_loader.cpp:line 211,276 1.1 set *'LibInfo libInfo = nullptr' (If no memory,new (std::nothrow) will return nullptr) 1.2 run vpl-timing with argument '-e' ( run 'MFXEnumImplementations '** function) 1.3 MFXEnumImplementations return 'MFX_ERR_NOT_FOUND',No memory leak,No crash,it is what we desired
libvpl/src/mfx_dispatcher_vpl_lowlatency.cpp:line 80