Commit 31532adf authored by Milan Broz's avatar Milan Broz

Do not copy buffer if read fails.

parent 879e06db
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment