From ade66816f1b94c49655f47d0980bbe3a8d89465e Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 7 Jan 2019 16:04:47 +0200 Subject: [PATCH] Fix invalid read A returned object will be destructed at the next sequence point. --- server/core/dcb.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/server/core/dcb.cc b/server/core/dcb.cc index 4c73262a2..2b0801edd 100644 --- a/server/core/dcb.cc +++ b/server/core/dcb.cc @@ -366,14 +366,24 @@ DCB* dcb_connect(SERVER* srv, MXS_SESSION* session, const char* protocol) dcb->remote = MXS_STRDUP_A(session->client_dcb->remote); } - const char* authenticator = !server->get_authenticator().empty() ? server->get_authenticator().c_str() : - (dcb->func.auth_default ? dcb->func.auth_default() : "NullAuthDeny"); + string authenticator = server->get_authenticator(); + if (authenticator.empty()) + { + if (dcb->func.auth_default) + { + authenticator = dcb->func.auth_default(); + } + else + { + authenticator = "NullAuthDeny"; + } + } - MXS_AUTHENTICATOR* authfuncs = (MXS_AUTHENTICATOR*)load_module(authenticator, + MXS_AUTHENTICATOR* authfuncs = (MXS_AUTHENTICATOR*)load_module(authenticator.c_str(), MODULE_AUTHENTICATOR); if (authfuncs == NULL) { - MXS_ERROR("Failed to load authenticator module '%s'", authenticator); + MXS_ERROR("Failed to load authenticator module '%s'", authenticator.c_str()); dcb_free_all_memory(dcb); return NULL; }