switch (command) {
case INPUT:
if (server->readonly) break;
-
- char *data = xmalloc(pss->len - 1);
- memcpy(data, pss->buffer + 1, pss->len - 1);
-
- uv_write_t *req = xmalloc(sizeof(uv_write_t));
- req->data = data;
-
- int err = pty_write(pss->process, pty_buf_init(data, pss->len - 1));
+ int err = pty_write(pss->process, pty_buf_init(pss->buffer + 1, pss->len - 1));
if (err) {
lwsl_err("uv_write: %s (%s)\n", uv_err_name(err), uv_strerror(err));
return -1;
}
int pty_write(pty_process *process, pty_buf_t *buf) {
- if (process == NULL) return UV_ESRCH;
+ if (process == NULL) {
+ pty_buf_free(buf);
+ return UV_ESRCH;
+ }
pty_io_t *io = process->io;
uv_buf_t b = uv_buf_init(buf->base, buf->len);
uv_write_t *req = xmalloc(sizeof(uv_write_t));