Description: Add null checking logic for the return value of new to DisplayManager: Impl:: UpdateDisplayInfoLocked.

IssueNo: https://gitee.com/openharmony/window_window_manager/issues/I92X1U
Signed-off-by: cuifeihe <cuifeihe@huawei.com>
This commit is contained in:
cuifeihe 2024-02-22 15:19:01 +08:00
parent 6540b8ebe0
commit a65f845a78

View File

@ -1314,7 +1314,11 @@ bool DisplayManager::Impl::UpdateDisplayInfoLocked(sptr<DisplayInfo> displayInfo
iter->second->UpdateDisplayInfo(displayInfo);
return true;
}
sptr<Display> display = new Display("", displayInfo);
sptr<Display> display = new (std::nothrow) Display("", displayInfo);
if (display == nullptr) {
WLOGFE("malloc display failed");
return false;
}
displayMap_[displayId] = display;
return true;
}