mirror of
https://github.com/allankoechke/soci.git
synced 2026-11-30 10:58:24 +00:00
Fix crash when using session after calling session:close()
If session_backend dtor threw an exception, backEnd_ remained pointing at an already destroyed object. Fix this by resetting it first in any case and deleting the object pointed to by it later. This notably affected session's own reconnect() function which could crash if the connection to the server was broken -- which is precisely when it's likely to be called.
This commit is contained in:
@@ -298,15 +298,16 @@ void session::open(std::string const & connectString)
|
||||
|
||||
void session::close()
|
||||
{
|
||||
auto* const backEnd = backEnd_;
|
||||
backEnd_ = NULL;
|
||||
|
||||
if (isFromPool_)
|
||||
{
|
||||
pool_->at(poolPosition_).close();
|
||||
backEnd_ = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete backEnd_;
|
||||
backEnd_ = NULL;
|
||||
delete backEnd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user