From ebba651c8125cac26e159d4094d15f826ed18055 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Wed, 15 Nov 2023 08:50:14 +0400 Subject: [PATCH] cogl/trace: Add check for failed sysprof context creation This can fail for example when passing an invalid filename to mutter --profile, which leads to assertion failures down the line. Part-of: --- cogl/cogl/cogl-trace.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cogl/cogl/cogl-trace.c b/cogl/cogl/cogl-trace.c index b4bc33452..e2b350517 100644 --- a/cogl/cogl/cogl-trace.c +++ b/cogl/cogl/cogl-trace.c @@ -102,6 +102,9 @@ cogl_trace_context_new (int fd, writer = sysprof_capture_writer_new (COGL_TRACE_OUTPUT_FILE, BUFFER_LENGTH); } + if (!writer) + return NULL; + context = g_new0 (CoglTraceContext, 1); context->writer = writer; g_atomic_ref_count_init (&context->ref_count); @@ -144,6 +147,13 @@ setup_trace_context (int fd, cogl_trace_context = cogl_trace_context_new (fd, filename); + if (!cogl_trace_context) + { + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "Failed to setup trace context"); + return FALSE; + } + return TRUE; }