mirror of
https://github.com/tsl0922/ttyd.git
synced 2025-12-23 04:14:18 +01:00
protocol: fix a regression that may crashes the server
This commit is contained in:
@@ -99,7 +99,8 @@ tty_client_remove(struct tty_client *client) {
|
|||||||
void
|
void
|
||||||
tty_client_destroy(struct tty_client *client) {
|
tty_client_destroy(struct tty_client *client) {
|
||||||
if (!client->running || client->pid <= 0)
|
if (!client->running || client->pid <= 0)
|
||||||
return;
|
goto cleanup;
|
||||||
|
|
||||||
client->running = false;
|
client->running = false;
|
||||||
|
|
||||||
// kill process and free resource
|
// 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);
|
lwsl_notice("process exited with code %d, pid: %d\n", status, client->pid);
|
||||||
close(client->pty);
|
close(client->pty);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
// free the buffer
|
// free the buffer
|
||||||
if (client->buffer != NULL)
|
if (client->buffer != NULL)
|
||||||
free(client->buffer);
|
free(client->buffer);
|
||||||
|
|||||||
Reference in New Issue
Block a user