mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Handle SharedMemory allocation failures
CreateSharedMemory is allowed to return nullptr if memory can't be allocated but DesktopFrameWin didn't check to ensure was allocated before accessing it. This CL just adds a null check, logs a warning, and returns nullptr which is already done lower in the function and the error is correctly handled in the screen and window capturers which call DesktopFrameWin::Create(). Bug: chromium:1251651 Change-Id: Ie9231f03ba9c7a96823af986b9df38f97fcb682c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232663 Reviewed-by: Jamie Walch <jamiewalch@chromium.org> Commit-Queue: Joe Downing <joedow@chromium.org> Cr-Commit-Position: refs/heads/main@{#35072}
This commit is contained in:
parent
98952d7f0f
commit
0529791ef7
1 changed files with 4 additions and 0 deletions
|
@ -50,6 +50,10 @@ std::unique_ptr<DesktopFrameWin> DesktopFrameWin::Create(
|
|||
HANDLE section_handle = nullptr;
|
||||
if (shared_memory_factory) {
|
||||
shared_memory = shared_memory_factory->CreateSharedMemory(buffer_size);
|
||||
if (!shared_memory) {
|
||||
RTC_LOG(LS_WARNING) << "Failed to allocate shared memory";
|
||||
return nullptr;
|
||||
}
|
||||
section_handle = shared_memory->handle();
|
||||
}
|
||||
void* data = nullptr;
|
||||
|
|
Loading…
Reference in a new issue