Fix a memory leak when psql connection fails
This commit is contained in:
1 parent
4a2a280d76
commit
505deda176
1 file changed
+1
@@ -34,6 +34,7 @@ std::unique_ptr<DatabaseEngine> PostgresqlEngine::open(const std::string& connin
|
||||
{
|
||||
const char* errmsg = PQerrorMessage(con);
|
||||
log_error("Postgresql connection failed: ", errmsg);
|
||||
PQfinish(con);
|
||||
throw std::runtime_error("failed to open connection.");
|
||||
}
|
||||
return std::make_unique<PostgresqlEngine>(con);
|
||||
|
||||
Reference in new issue
Block a user