mirror of
https://github.com/ckolivas/lrzip.git
synced 2026-04-05 06:15:28 +00:00
Deallocate runzip structures after all runzip chunks are complete to avoid a race in the case of a failed chunk decompressing.
This commit is contained in:
parent
2c7c4832b3
commit
be884d09e0
3 changed files with 48 additions and 4 deletions
19
runzip.c
19
runzip.c
|
|
@ -246,6 +246,21 @@ static i64 unzip_match(rzip_control *control, void *ss, i64 len, uint32 *cksum,
|
|||
return total;
|
||||
}
|
||||
|
||||
static void clear_rulist(rzip_control *control)
|
||||
{
|
||||
while (control->ruhead) {
|
||||
struct runzip_node *node = control->ruhead;
|
||||
struct stream_info *sinfo = node->sinfo;
|
||||
|
||||
dealloc(sinfo->ucthreads);
|
||||
dealloc(node->pthreads);
|
||||
dealloc(sinfo->s);
|
||||
dealloc(sinfo);
|
||||
control->ruhead = node->prev;
|
||||
dealloc(node);
|
||||
}
|
||||
}
|
||||
|
||||
/* decompress a section of an open file. Call fatal_return(() on error
|
||||
return the number of bytes that have been retrieved
|
||||
*/
|
||||
|
|
@ -363,6 +378,10 @@ static i64 runzip_chunk(rzip_control *control, int fd_in, i64 expected_size, i64
|
|||
if (unlikely(close_stream_in(control, ss)))
|
||||
fatal("Failed to close stream!\n");
|
||||
|
||||
/* We can now safely delete sinfo and pthread data of all threads
|
||||
* created. */
|
||||
clear_rulist(control);
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue