Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak during child process exit code checking #143

Merged
merged 1 commit into from
Apr 24, 2024
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
12 changes: 6 additions & 6 deletions app/dockerdwrapperwithcompose.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,22 +440,22 @@ static bool read_settings(struct settings* settings, const struct app_state* app
return true;
}

static struct exit_cause child_process_exit_cause(int status, GError* error) {
static struct exit_cause child_process_exit_cause(int status, GError** error) {
struct exit_cause result;
result.code = -1;
result.signal = 0;

if (g_spawn_check_wait_status(status, &error) || error->domain == G_SPAWN_EXIT_ERROR)
result.code = error ? error->code : 0;
else if (error->domain == G_SPAWN_ERROR && error->code == G_SPAWN_ERROR_FAILED)
if (g_spawn_check_wait_status(status, error) || (*error)->domain == G_SPAWN_EXIT_ERROR)
result.code = *error ? (*error)->code : 0;
else if ((*error)->domain == G_SPAWN_ERROR && (*error)->code == G_SPAWN_ERROR_FAILED)
result.signal = status;

return result;
}

static void log_child_process_exit_cause(const char* name, GPid pid, int status) {
GError* error = NULL;
struct exit_cause exit_cause = child_process_exit_cause(status, error);
struct exit_cause exit_cause = child_process_exit_cause(status, &error);

char msg[128];
const char* end = msg + sizeof(msg);
Expand All @@ -472,7 +472,7 @@ static void log_child_process_exit_cause(const char* name, GPid pid, int status)

static bool child_process_exited_with_error(int status) {
GError* error = NULL;
struct exit_cause exit_cause = child_process_exit_cause(status, error);
struct exit_cause exit_cause = child_process_exit_cause(status, &error);
g_clear_error(&error);
return exit_cause.code > 0;
}
Expand Down