main: Fix ctl-server use after free

v0.8
Andri Yngvason 2023-12-10 19:02:55 +00:00
parent 830142701a
commit a7ed782bb9
1 changed files with 14 additions and 8 deletions

View File

@ -469,6 +469,7 @@ static void wayland_detach(struct wayvnc* self)
wl_display_disconnect(self->display);
self->display = NULL;
if (self->ctl)
ctl_server_event_detached(self->ctl);
}
@ -1274,14 +1275,18 @@ static void client_destroy(void* obj)
nvnc_log(NVNC_LOG_DEBUG, "Client disconnected, new client count: %d",
wayvnc->nr_clients);
if (wayvnc->ctl) {
struct ctl_server_client_info info = {
.id = self->id,
.hostname = nvnc_client_get_hostname(self->nvnc_client),
.username = nvnc_client_get_auth_username(self->nvnc_client),
.username = nvnc_client_get_auth_username(
self->nvnc_client),
.seat = self->seat ? self->seat->name : NULL,
};
ctl_server_event_disconnected(wayvnc->ctl, &info, wayvnc->nr_clients);
ctl_server_event_disconnected(wayvnc->ctl, &info,
wayvnc->nr_clients);
}
if (wayvnc->nr_clients == 0 && wayvnc->display) {
nvnc_log(NVNC_LOG_INFO, "Stopping screen capture");
@ -1938,6 +1943,7 @@ int main(int argc, char* argv[])
screencopy_stop(&self.screencopy);
ctl_server_destroy(self.ctl);
self.ctl = NULL;
nvnc_display_unref(self.nvnc_display);
nvnc_close(self.nvnc);