From 8c5c93acba03f0b09dccb1e83f4959e2882018d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Fri, 14 Jun 2024 11:16:56 +0200 Subject: [PATCH] wsi: Make sure to return a valid wayland id string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The result of asprintf was previously ignored, handle the case of failure by not returning undefined content. Signed-off-by: Corentin Noël Part-of: --- src/vulkan/wsi/wsi_common_wayland.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index caa16743fc1..f6f887b467e 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -242,7 +242,9 @@ stringify_wayland_id(uint32_t id) { char *out; - asprintf(&out, "wl%d", id); + if (asprintf(&out, "wl%d", id) < 0) + return NULL; + return out; } @@ -1991,7 +1993,7 @@ trace_present(const struct wsi_wl_present_id *id, /* Close the previous image display interval first, if there is one. */ if (surface->analytics.presenting && util_perfetto_is_tracing_enabled()) { buffer_name = stringify_wayland_id(surface->analytics.presenting); - MESA_TRACE_TIMESTAMP_END(buffer_name, + MESA_TRACE_TIMESTAMP_END(buffer_name ? buffer_name : "Wayland buffer", surface->analytics.presentation_track_id, presentation_time); free(buffer_name); @@ -2001,7 +2003,7 @@ trace_present(const struct wsi_wl_present_id *id, if (util_perfetto_is_tracing_enabled()) { buffer_name = stringify_wayland_id(id->buffer_id); - MESA_TRACE_TIMESTAMP_BEGIN(buffer_name, + MESA_TRACE_TIMESTAMP_BEGIN(buffer_name ? buffer_name : "Wayland buffer", surface->analytics.presentation_track_id, id->flow_id, presentation_time);