in high sierra, estimated read size always seems to be 0. handle that situation.

This commit is contained in:
Kelvin Sherlock 2018-01-18 15:43:13 -05:00
parent de8810b8e2
commit a6408fc242
1 changed files with 2 additions and 2 deletions

View File

@ -236,7 +236,7 @@
static uint8_t sbuffer[1024];
size_t estimated = dispatch_source_get_data(_read_source);
estimated = std::max(estimated, sizeof(sbuffer));
uint8_t *buffer = estimated > sizeof(sbuffer) ? (uint8_t *)malloc(estimated) : sbuffer;
if (buffer)
@ -244,7 +244,7 @@
ssize_t actual;
for (;;) {
actual = read(fd, buffer, (estimated));
actual = read(fd, buffer, estimated);
if (actual < 0) {
if (errno == EINTR) continue;