mirror of
https://github.com/neovim/neovim.git
synced 2025-10-18 07:41:51 +00:00
win/pty: jobstart, jobstop: fix null-pointer dereference
- Make sure that proc->in is not NULL, because nvim crashed when starting a job with pty. - Make sure that proc->out is not NULL, because nvim crashed when stopping a job opened with pty.
This commit is contained in:
@@ -19,7 +19,7 @@ static void wait_eof_timer_cb(uv_timer_t *wait_eof_timer)
|
|||||||
(PtyProcess *)((uv_handle_t *)wait_eof_timer->data);
|
(PtyProcess *)((uv_handle_t *)wait_eof_timer->data);
|
||||||
Process *proc = (Process *)ptyproc;
|
Process *proc = (Process *)ptyproc;
|
||||||
|
|
||||||
if (!uv_is_readable(proc->out->uvstream)) {
|
if (!proc->out || !uv_is_readable(proc->out->uvstream)) {
|
||||||
uv_timer_stop(&ptyproc->wait_eof_timer);
|
uv_timer_stop(&ptyproc->wait_eof_timer);
|
||||||
pty_process_finish2(ptyproc);
|
pty_process_finish2(ptyproc);
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ int pty_process_spawn(PtyProcess *ptyproc)
|
|||||||
uv_connect_t *in_req = NULL, *out_req = NULL;
|
uv_connect_t *in_req = NULL, *out_req = NULL;
|
||||||
wchar_t *cmdline = NULL, *cwd = NULL;
|
wchar_t *cmdline = NULL, *cwd = NULL;
|
||||||
|
|
||||||
assert(proc->in && proc->out && !proc->err);
|
assert(!proc->err);
|
||||||
|
|
||||||
if (!(cfg = winpty_config_new(
|
if (!(cfg = winpty_config_new(
|
||||||
WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION, &err))) {
|
WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION, &err))) {
|
||||||
@@ -71,18 +71,22 @@ int pty_process_spawn(PtyProcess *ptyproc)
|
|||||||
if ((status = utf16_to_utf8(winpty_conout_name(wp), &out_name))) {
|
if ((status = utf16_to_utf8(winpty_conout_name(wp), &out_name))) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
in_req = xmalloc(sizeof(uv_connect_t));
|
if (proc->in) {
|
||||||
out_req = xmalloc(sizeof(uv_connect_t));
|
in_req = xmalloc(sizeof(uv_connect_t));
|
||||||
uv_pipe_connect(
|
uv_pipe_connect(
|
||||||
in_req,
|
in_req,
|
||||||
&proc->in->uv.pipe,
|
&proc->in->uv.pipe,
|
||||||
in_name,
|
in_name,
|
||||||
pty_process_connect_cb);
|
pty_process_connect_cb);
|
||||||
uv_pipe_connect(
|
}
|
||||||
out_req,
|
if (proc->out) {
|
||||||
&proc->out->uv.pipe,
|
out_req = xmalloc(sizeof(uv_connect_t));
|
||||||
out_name,
|
uv_pipe_connect(
|
||||||
pty_process_connect_cb);
|
out_req,
|
||||||
|
&proc->out->uv.pipe,
|
||||||
|
out_name,
|
||||||
|
pty_process_connect_cb);
|
||||||
|
}
|
||||||
|
|
||||||
if (proc->cwd != NULL && (status = utf8_to_utf16(proc->cwd, &cwd))) {
|
if (proc->cwd != NULL && (status = utf8_to_utf16(proc->cwd, &cwd))) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@@ -107,7 +111,7 @@ int pty_process_spawn(PtyProcess *ptyproc)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (in_req->handle || out_req->handle) {
|
while ((in_req && in_req->handle) || (out_req && out_req->handle)) {
|
||||||
uv_run(&proc->loop->uv, UV_RUN_ONCE);
|
uv_run(&proc->loop->uv, UV_RUN_ONCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user