Skip to content

Commit

Permalink
main: Fix double nvnc_close()
Browse files Browse the repository at this point in the history
  • Loading branch information
layercak3 authored and any1 committed Oct 1, 2024
1 parent fa3f25c commit 65c10e5
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ static int init_nvnc(struct wayvnc* self, const char* addr, uint16_t port,

self->nvnc_display = nvnc_display_new(0, 0);
if (!self->nvnc_display)
goto failure;
goto display_failure;

nvnc_add_display(self->nvnc, self->nvnc_display);

Expand All @@ -947,7 +947,7 @@ static int init_nvnc(struct wayvnc* self, const char* addr, uint16_t port,
if (self->cfg.enable_auth) {
if (nvnc_enable_auth(self->nvnc, auth_flags, on_auth, self) < 0) {
nvnc_log(NVNC_LOG_ERROR, "Failed to enable authentication");
goto failure;
goto auth_failure;
}

if (self->cfg.rsa_private_key_file) {
Expand All @@ -956,7 +956,7 @@ static int init_nvnc(struct wayvnc* self, const char* addr, uint16_t port,
self->cfg.rsa_private_key_file);
if (nvnc_set_rsa_creds(self->nvnc, key_file) < 0) {
nvnc_log(NVNC_LOG_ERROR, "Failed to load RSA credentials");
goto failure;
goto auth_failure;
}
}

Expand All @@ -972,7 +972,7 @@ static int init_nvnc(struct wayvnc* self, const char* addr, uint16_t port,
cert_file);
if (r < 0) {
nvnc_log(NVNC_LOG_ERROR, "Failed to enable TLS authentication");
goto failure;
goto auth_failure;
}
}
}
Expand All @@ -986,11 +986,14 @@ static int init_nvnc(struct wayvnc* self, const char* addr, uint16_t port,
nvnc_set_cut_text_fn(self->nvnc, on_client_cut_text);

if (blank_screen(self) != 0)
goto failure;
goto blank_screen_failure;

return 0;

failure:
blank_screen_failure:
auth_failure:
nvnc_display_unref(self->nvnc_display);
display_failure:
nvnc_close(self->nvnc);
return -1;
}
Expand Down Expand Up @@ -2130,8 +2133,6 @@ int main(int argc, char* argv[])
ctl_server_destroy(self.ctl);
ctl_server_failure:
screencopy_failure:
nvnc_display_unref(self.nvnc_display);
nvnc_close(self.nvnc);
wayland_failure:
aml_unref(aml);
failure:
Expand Down

0 comments on commit 65c10e5

Please sign in to comment.