Skip to content
Permalink
Browse files
MDEV-28719: compress_write() leaks data_mutex on error
  • Loading branch information
dr-m committed Jun 1, 2022
1 parent fde99e0 commit 91d5fff
Showing 1 changed file with 11 additions and 12 deletions.
@@ -238,25 +238,24 @@ compress_write(ds_file_t *file, const uchar *buf, size_t len)

xb_a(threads[i].to_len > 0);

if (ds_write(dest_file, "NEWBNEWB", 8) ||
write_uint64_le(dest_file,
comp_file->bytes_processed)) {
msg("compress: write to the destination stream "
"failed.");
return 1;
bool fail = ds_write(dest_file, "NEWBNEWB", 8) ||
write_uint64_le(dest_file,
comp_file->bytes_processed);
comp_file->bytes_processed += threads[i].from_len;

if (!fail) {
fail = write_uint32_le(dest_file, threads[i].adler) ||
ds_write(dest_file, threads[i].to,
threads[i].to_len);
}

comp_file->bytes_processed += threads[i].from_len;
pthread_mutex_unlock(&threads[i].data_mutex);

if (write_uint32_le(dest_file, threads[i].adler) ||
ds_write(dest_file, threads[i].to,
threads[i].to_len)) {
if (fail) {
msg("compress: write to the destination stream "
"failed.");
return 1;
}

pthread_mutex_unlock(&threads[i].data_mutex);
}
}

0 comments on commit 91d5fff

Please sign in to comment.