Merge pull request #1825 from G10h4ck/android_fix_debug_crash

Fix crash on Android due to dangling reference
This commit is contained in:
csoler 2020-03-06 22:00:08 +01:00 committed by GitHub
commit e5b53e5646
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -465,14 +465,17 @@ void JsonApiServer::registerHandler(
const std::shared_ptr<rb::Session> session,
const std::function<void (const std::shared_ptr<rb::Session>)>& callback )
{
/* Declare outside the lambda to avoid returning a dangling
* reference on Android */
RsWarn tWarn;
const auto authFail =
[&path, &session](int status) -> RsWarn::stream_type&
[&](int status) -> RsWarn::stream_type&
{
/* Capture session by reference as it is cheaper then copying
* shared_ptr by value which is not needed in this case */
session->close(status, corsOptionsHeaders);
return RsWarn() << "JsonApiServer authentication handler "
return tWarn << "JsonApiServer authentication handler "
"blocked an attempt to call JSON API "
"authenticated method: " << path;
};