From d05334bd8612bfdef8fb61167226727a5709dd23 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 10 Jun 2016 21:04:42 +1000 Subject: [PATCH] checksum.buf should only be changed after the semaphore wait --- main.c | 4 ++-- rzip.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index e45595a..3a4f7ed 100644 --- a/main.c +++ b/main.c @@ -578,8 +578,8 @@ int main(int argc, char *argv[]) recursion: if (recurse) { if (curentry >= direntries) { - free(dirlist); - break; + infile = NULL; + continue; } infile = dirlist + MAX_PATH_LEN * curentry++; } diff --git a/rzip.c b/rzip.c index 56a9291..2bd444f 100644 --- a/rzip.c +++ b/rzip.c @@ -744,11 +744,11 @@ static inline void hash_search(rzip_control *control, struct rzip_state *st, if (cksum_len < control->page_size) failure("Failed to malloc any ram for checksum ckbuf\n"); } - control->checksum.buf = buf; /* Compute checksum. If the entire chunk is longer than maxram, * do it "per-partes" */ cksem_wait(control, &control->cksumsem); + control->checksum.buf = buf; control->checksum.len = st->chunk_size - cksum_limit; cksum_chunks = control->checksum.len / cksum_len; cksum_remains = control->checksum.len % cksum_len;