Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/libcrun/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -3297,7 +3297,11 @@ libcrun_container_create (libcrun_context_t *context, libcrun_container_t *conta

ret = libcrun_copy_config_file (context->id, context->state_root, container, err);
if (UNLIKELY (ret < 0))
libcrun_fail_with_error (errno, "copy config file");
{
int errcode = crun_error_get_errno (err);
crun_error_release (err);
libcrun_fail_with_error (errcode, "copy config file");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Thank you for fixing the error handling here. This correctly uses the errno from the err object and prevents a memory leak. However, libcrun_container_create is a library function that should return an error to its caller, not terminate the process with exit(). The libcrun_fail_with_error function is noreturn.

A few lines below, for the error from libcrun_container_run_internal, the code correctly returns an error. We should follow the same pattern here and use crun_make_error to create and return an error.

      return crun_make_error (err, errcode, "copy config file");

}

ret = libcrun_container_run_internal (container, context, &pipefd1, err);
if (UNLIKELY (ret < 0))
Expand Down