Do not copy buffer if read fails.

This commit is contained in:
Milan Broz
2018-10-11 15:39:31 +02:00
parent 879e06db39
commit 31532adf86

View File

@@ -184,7 +184,8 @@ ssize_t read_blockwise(int fd, size_t bsize, size_t alignment,
out:
free(hangover_buf);
if (buf != orig_buf) {
memcpy(orig_buf, buf, length);
if (ret == length)
memcpy(orig_buf, buf, length);
free(buf);
}
return ret;