summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-06-01 11:20:47 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2022-06-01 11:20:47 +0300
commit91d5fffa0796b8208c3d6633c8f296da8914af4d (patch)
tree97839dd076b1099cec54f15ad9ee5e120aca78dc
parentfde99e006d0947977f196854dd1f5a2eaa030c20 (diff)
downloadmariadb-git-91d5fffa0796b8208c3d6633c8f296da8914af4d.tar.gz
MDEV-28719: compress_write() leaks data_mutex on error
-rw-r--r--extra/mariabackup/ds_compress.cc23
1 files changed, 11 insertions, 12 deletions
diff --git a/extra/mariabackup/ds_compress.cc b/extra/mariabackup/ds_compress.cc
index dcfb3d5a82f..39a72cdca34 100644
--- a/extra/mariabackup/ds_compress.cc
+++ b/extra/mariabackup/ds_compress.cc
@@ -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);
}
}