postgis: avoid potential crash if connection is not initialized

This commit is contained in:
Dane Springmeyer 2013-04-02 11:24:38 -07:00
parent 42d7263cab
commit c6fd387469

View file

@ -53,7 +53,7 @@ public:
{
std::ostringstream s;
s << "Postgis Plugin: ";
if (conn_ )
if (conn_)
{
std::string msg = PQerrorMessage(conn_);
if (! msg.empty())
@ -64,14 +64,13 @@ public:
{
s << "unable to connect to postgres server";
}
PQfinish(conn_);
}
else
{
s << "unable to connect to postgres server";
}
s << "\n" << connection_str;
PQfinish(conn_);
throw mapnik::datasource_exception(s.str());
}
}