checksum.buf should only be changed after the semaphore wait

This commit is contained in:
Con Kolivas 2016-06-10 21:04:42 +10:00
parent a2796607d9
commit d05334bd86
2 changed files with 3 additions and 3 deletions

4
main.c
View file

@ -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++;
}

2
rzip.c
View file

@ -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;