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