diff --git a/runzip.c b/runzip.c index 94239bb..e0a0505 100644 --- a/runzip.c +++ b/runzip.c @@ -179,7 +179,7 @@ static i64 runzip_chunk(int fd_in, int fd_out, int fd_hist, i64 expected_size, i if (ofs == -1) fatal("Failed to seek input file in runzip_fd\n"); - if (fstat(fd_in, &st) != 0 || st.st_size-ofs == 0) + if (fstat(fd_in, &st) != 0 || st.st_size - ofs == 0) return 0; ss = open_stream_in(fd_in, NUM_STREAMS); diff --git a/stream.c b/stream.c index d471539..2610137 100644 --- a/stream.c +++ b/stream.c @@ -831,10 +831,11 @@ static int fill_buffer(struct stream_info *sinfo, int stream) sinfo->total_read += header_length; if (sinfo->s[stream].buf) - free(sinfo->s[stream].buf); - sinfo->s[stream].buf = malloc(u_len); + sinfo->s[stream].buf = realloc(sinfo->s[stream].buf, u_len); + else + sinfo->s[stream].buf = malloc(u_len); if (!sinfo->s[stream].buf) - return -1; + fatal("Unable to malloc buffer of size %lld in fill_buffer\n", u_len); if (read_buf(sinfo->fd, sinfo->s[stream].buf, c_len) != 0) return -1;