summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2021-09-15 14:55:45 +0200
committerVladislav Vaintroub <wlad@mariadb.com>2021-09-15 14:55:45 +0200
commitb1351c15946349f9daa7e5297fb2ac6f3139e4a8 (patch)
tree27854fa258de84e5d13f046a1f6f37ac570f6344
parent8937762ead9623f4bcd23d445319c08e07d6c321 (diff)
downloadmariadb-git-b1351c15946349f9daa7e5297fb2ac6f3139e4a8.tar.gz
MDEV-26574 An improper locking bug due to unreleased lock in the ds_xbstream.cc
release lock in all as cases n xbstream_open, also fix the case where malloc would return NULL.
-rw-r--r--extra/mariabackup/ds_xbstream.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/extra/mariabackup/ds_xbstream.cc b/extra/mariabackup/ds_xbstream.cc
index 3b60456f8ed..798d7da6da4 100644
--- a/extra/mariabackup/ds_xbstream.cc
+++ b/extra/mariabackup/ds_xbstream.cc
@@ -126,15 +126,19 @@ xbstream_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat)
pthread_mutex_lock(&stream_ctxt->mutex);
if (stream_ctxt->dest_file == NULL) {
stream_ctxt->dest_file = ds_open(dest_ctxt, path, mystat);
- if (stream_ctxt->dest_file == NULL) {
- return NULL;
- }
}
pthread_mutex_unlock(&stream_ctxt->mutex);
+ if (stream_ctxt->dest_file == NULL) {
+ return NULL;
+ }
file = (ds_file_t *) my_malloc(sizeof(ds_file_t) +
sizeof(ds_stream_file_t),
MYF(MY_FAE));
+ if (!file) {
+ msg("my_malloc() failed.");
+ goto err;
+ }
stream_file = (ds_stream_file_t *) (file + 1);
xbstream = stream_ctxt->xbstream;