mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Fix segfault from thread race condition during decompression.
This fixes an issue where the main thread would not wait for all worker threads to fully join before attempting to process their result buffers: new_thread was true up until to the final N-1 calls, at which point the input stream will have ended and new_thread would be false, then bypassing the pthread_join()s. The new_thread condition isn't actually necessary at all, so it has been entirely removed.
This commit is contained in:
parent
9819e861a5
commit
1a1723834b
4
stream.c
4
stream.c
|
|
@ -1567,14 +1567,12 @@ static int fill_buffer(rzip_control *control, struct stream_info *sinfo, struct
|
|||
i64 u_len, c_len, last_head, padded_len, header_length, max_len;
|
||||
uchar enc_head[25 + SALT_LEN], blocksalt[SALT_LEN];
|
||||
stream_thread_struct *st;
|
||||
bool new_thread = false;
|
||||
uchar c_type, *s_buf;
|
||||
|
||||
dealloc(s->buf);
|
||||
if (s->eos)
|
||||
goto out;
|
||||
fill_another:
|
||||
new_thread = true;
|
||||
if (unlikely(ucthread[s->uthread_no].busy))
|
||||
failure_return(("Trying to start a busy thread, this shouldn't happen!\n"), -1);
|
||||
|
||||
|
|
@ -1704,7 +1702,7 @@ out:
|
|||
unlock_mutex(control, &output_lock);
|
||||
|
||||
/* join_pthread here will make it wait till the data is ready */
|
||||
if (unlikely(new_thread && !join_pthread(control, threads[s->unext_thread], NULL)))
|
||||
if (unlikely(!join_pthread(control, threads[s->unext_thread], NULL)))
|
||||
return -1;
|
||||
ucthread[s->unext_thread].busy = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue