diff --git a/src/compress.c b/src/compress.c index ba1e3d7..6846d66 100644 --- a/src/compress.c +++ b/src/compress.c @@ -932,23 +932,23 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, const unsigned char *old, rv = OKDATA; r = sread(fdp[STDOUT_FILENO][0], *newch, bytes_max, 0); if (r <= 0) { - DPRINTF("Read stdout failed %d (%s)\n", fdp[STDOUT_FILENO][0], - r != -1 ? strerror(errno) : "no data"); - - rv = ERRDATA; - if (r == 0 && - (r = sread(fdp[STDERR_FILENO][0], *newch, bytes_max, 0)) > 0) - { - r = filter_error(*newch, r); - goto ok; - } - free(*newch); - if (r == 0) - rv = makeerror(newch, n, "Read failed, %s", - strerror(errno)); - else - rv = makeerror(newch, n, "No data"); - goto err; + if (r < 0) { + rv = ERRDATA; + DPRINTF("Read stdout failed %d (%s)\n", fdp[STDOUT_FILENO][0], + strerror(errno)); + goto err; + } else if ((r = sread(fdp[STDERR_FILENO][0], *newch, bytes_max, 0)) > 0){ + rv = ERRDATA; + r = filter_error(*newch, r); + goto ok; + } + if (r == 0) + goto ok; + free(*newch); + rv = ERRDATA; + rv = makeerror(newch, n, "Read stderr failed, %s", + strerror(errno)); + goto err; } ok: *n = r;