mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 11:31:53 +01:00
fixed a memory leak when opening a SQLite database fails
This commit is contained in:
@@ -54,8 +54,8 @@ SessionImpl::SessionImpl(const std::string& fileName, std::size_t loginTimeout):
|
|||||||
open();
|
open();
|
||||||
setConnectionTimeout(loginTimeout);
|
setConnectionTimeout(loginTimeout);
|
||||||
setProperty("handle", _pDB);
|
setProperty("handle", _pDB);
|
||||||
addFeature("autoCommit",
|
addFeature("autoCommit",
|
||||||
&SessionImpl::autoCommit,
|
&SessionImpl::autoCommit,
|
||||||
&SessionImpl::isAutoCommit);
|
&SessionImpl::isAutoCommit);
|
||||||
addProperty("connectionTimeout", &SessionImpl::setConnectionTimeout, &SessionImpl::getConnectionTimeout);
|
addProperty("connectionTimeout", &SessionImpl::setConnectionTimeout, &SessionImpl::getConnectionTimeout);
|
||||||
}
|
}
|
||||||
@@ -163,14 +163,15 @@ void SessionImpl::open(const std::string& connect)
|
|||||||
if (rc == SQLITE_OK) break;
|
if (rc == SQLITE_OK) break;
|
||||||
if (sw.elapsedSeconds() >= tout)
|
if (sw.elapsedSeconds() >= tout)
|
||||||
{
|
{
|
||||||
close();
|
|
||||||
Utility::throwException(_pDB, rc);
|
Utility::throwException(_pDB, rc);
|
||||||
}
|
}
|
||||||
else Thread::sleep(10);
|
Thread::sleep(10);
|
||||||
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SQLiteException& ex)
|
catch (SQLiteException& ex)
|
||||||
{
|
{
|
||||||
|
close();
|
||||||
throw ConnectionFailedException(ex.displayText());
|
throw ConnectionFailedException(ex.displayText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3368,7 +3368,7 @@ void SQLiteTest::testIllegalFilePath()
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Session tmp (Poco::Data::SQLite::Connector::KEY, "\\/some\\/illegal\\/path\\/dummy.db", 1);
|
Session tmp(Poco::Data::SQLite::Connector::KEY, "\\/some\\/illegal\\/path\\/dummy.db", 1);
|
||||||
fail("must fail");
|
fail("must fail");
|
||||||
}
|
}
|
||||||
catch (ConnectionFailedException&)
|
catch (ConnectionFailedException&)
|
||||||
|
|||||||
Reference in New Issue
Block a user