Call PQfinish after PQerrorMessage when connection fails

This commit is contained in:
Sean Pringle 2016-05-16 10:08:58 +10:00
parent 309570578e
commit f12bedd987

View File

@ -510,8 +510,9 @@ static int env_connect (lua_State *L) {
conn = PQsetdbLogin(pghost, pgport, NULL, NULL, sourcename, username, password);
if (PQstatus(conn) == CONNECTION_BAD) {
int rc = luasql_failmsg(L, "error connecting to database. PostgreSQL: ", PQerrorMessage(conn));
PQfinish(conn);
return luasql_failmsg(L, "error connecting to database. PostgreSQL: ", PQerrorMessage(conn));
return rc;
}
PQsetNoticeProcessor(conn, notice_processor, NULL);
return create_connection(L, 1, conn);