1
0
Fork 0

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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3397>
This commit is contained in:
Ivan Molodetskikh 2023-11-15 08:50:14 +04:00
parent ca5bf847ee
commit ebba651c81

View file

@ -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;
}