summaryrefslogtreecommitdiffstats
path: root/src/pty.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-10-21 09:24:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-10-21 09:24:51 +0000
commit97d4bdd0effbdc675e8c136ed72c43e7898385d8 (patch)
tree9bbb2849cc74e0751e4eb9e122dd3e9d5c23be2d /src/pty.c
parentAdding upstream version 1.7.1. (diff)
downloadttyd-97d4bdd0effbdc675e8c136ed72c43e7898385d8.tar.xz
ttyd-97d4bdd0effbdc675e8c136ed72c43e7898385d8.zip
Adding upstream version 1.7.2.upstream/1.7.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/pty.c')
-rw-r--r--src/pty.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/pty.c b/src/pty.c
index 7bf62f4..adfcc3e 100644
--- a/src/pty.c
+++ b/src/pty.c
@@ -42,6 +42,10 @@ static void alloc_cb(uv_handle_t *unused, size_t suggested_size, uv_buf_t *buf)
static void close_cb(uv_handle_t *handle) { free(handle); }
+static void async_free_cb(uv_handle_t *handle) {
+ free((uv_async_t *) handle -> data);
+}
+
pty_buf_t *pty_buf_init(char *base, size_t len) {
pty_buf_t *buf = xmalloc(sizeof(pty_buf_t));
buf->base = xmalloc(len);
@@ -114,7 +118,6 @@ void process_free(pty_process *process) {
char **p = process->envp;
for (; *p; p++) free(*p);
free(process->envp);
- free(process);
}
void pty_pause(pty_process *process) {
@@ -307,7 +310,7 @@ static void async_cb(uv_async_t *async) {
process->exit_signal = 1;
process->exit_cb(process);
- uv_close((uv_handle_t *) async, NULL);
+ uv_close((uv_handle_t *) async, async_free_cb);
process_free(process);
}
@@ -420,7 +423,7 @@ static void async_cb(uv_async_t *async) {
pty_process *process = (pty_process *) async->data;
process->exit_cb(process);
- uv_close((uv_handle_t *) async, NULL);
+ uv_close((uv_handle_t *) async, async_free_cb);
process_free(process);
}