From 710aa1cd98d065fa07743635870167f415ad2e1a Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Wed, 10 Jan 2018 00:09:30 +0800 Subject: [PATCH] protocol: fix a regression that may crashes the server --- src/protocol.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/protocol.c b/src/protocol.c index 70fdc6c..845718c 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -99,7 +99,8 @@ tty_client_remove(struct tty_client *client) { void tty_client_destroy(struct tty_client *client) { if (!client->running || client->pid <= 0) - return; + goto cleanup; + client->running = false; // kill process and free resource @@ -113,6 +114,7 @@ tty_client_destroy(struct tty_client *client) { lwsl_notice("process exited with code %d, pid: %d\n", status, client->pid); close(client->pty); +cleanup: // free the buffer if (client->buffer != NULL) free(client->buffer); -- 2.43.4