Read errors from child must commit a zero write

This commit is contained in:
Kovid Goyal
2023-11-05 10:36:51 +05:30
parent 6205fb32fd
commit 34164dc341
2 changed files with 3 additions and 2 deletions

View File

@@ -1343,13 +1343,13 @@ read_bytes(int fd, Screen *screen) {
if (len < 0) {
if (errno == EINTR || errno == EAGAIN) continue;
if (errno != EIO) perror("Call to read() from child fd failed");
vt_parser_commit_write(screen->vt_parser, 0);
return false;
}
break;
}
vt_parser_commit_write(screen->vt_parser, len);
if (UNLIKELY(len == 0)) return false;
return true;
return len != 0;
}

View File

@@ -1581,6 +1581,7 @@ vt_parser_create_write_buffer(Parser *p, size_t *sz) {
PS *self = (PS*)p->state;
uint8_t *ans;
with_lock {
if (self->write.sz) fatal("vt_parser_create_write_buffer() called with an already existing write buffer");
*sz = BUF_SZ - self->read.sz;
self->write.offset = self->read.sz;
self->write.sz = *sz;