From 7435f6989f2471548caccc20ae3bbe48e315f303 Mon Sep 17 00:00:00 2001 From: qiujiacai Date: Fri, 22 Sep 2023 12:39:27 +0800 Subject: [PATCH] Add error log and check the return value of the function --- wayland_adapter/framework/core/wayland_surface.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wayland_adapter/framework/core/wayland_surface.cpp b/wayland_adapter/framework/core/wayland_surface.cpp index 4c7ca4f..275424b 100644 --- a/wayland_adapter/framework/core/wayland_surface.cpp +++ b/wayland_adapter/framework/core/wayland_surface.cpp @@ -231,10 +231,15 @@ OHOS::sptr WaylandSurface::Create(struct wl_client *client, struct wl_resource *parent, uint32_t version, uint32_t id) { if (client == nullptr) { + LOG_ERROR("Invalid client parameter"); return nullptr; } auto surface = OHOS::sptr(new WaylandSurface(client, parent, version, id)); + if (surface == nullptr) { + LOG_ERROR("Failed to create WaylandSurface"); + return nullptr; + } WaylandObjectsPool::GetInstance().AddObject(ObjectId(surface->WlClient(), surface->Id()), surface); return surface; } -- Gitee