Blob Blame History Raw
diff --git a/src/compress.c b/src/compress.c
index cb11303..5677412 100644
--- a/src/compress.c
+++ b/src/compress.c
@@ -723,25 +723,24 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, const unsigned char *old,
 		rv = OKDATA;
 		if ((r = sread(fdp[STDOUT_FILENO][0], *newch, bytes_max, 0)) > 0)
 			break;
-		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)
-		{
+		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);
 			break;
 		}
-		free(*newch);
 		if  (r == 0)
-			rv = makeerror(newch, n, "Read failed, %s",
-			    strerror(errno));
-		else
-			rv = makeerror(newch, n, "No data");
+			break;
+		free(*newch);
+		rv = ERRDATA;
+		rv = makeerror(newch, n, "Read stderr failed, %s",
+		    strerror(errno));
 		goto err;
 	}
-
 	*n = r;
 	/* NUL terminate, as every buffer is handled here. */
 	(*newch)[*n] = '\0';