Fix a memory leak when psql connection fails

This commit is contained in:
louiz’
2018-02-14 23:25:12 +01:00
parent 4a2a280d76
commit 505deda176
+1
View File
@@ -34,6 +34,7 @@ std::unique_ptr<DatabaseEngine> PostgresqlEngine::open(const std::string& connin
{ {
const char* errmsg = PQerrorMessage(con); const char* errmsg = PQerrorMessage(con);
log_error("Postgresql connection failed: ", errmsg); log_error("Postgresql connection failed: ", errmsg);
PQfinish(con);
throw std::runtime_error("failed to open connection."); throw std::runtime_error("failed to open connection.");
} }
return std::make_unique<PostgresqlEngine>(con); return std::make_unique<PostgresqlEngine>(con);