When trying to connect to a given database libecpg should not try using an
empty hostname if no hostname was given.
if (dbname != NULL)
{
- /* get the detail information out of dbname */
+ /* get the detail information from dbname */
if (strncmp(dbname, "tcp:", 4) == 0 || strncmp(dbname, "unix:", 5) == 0)
{
int offset = 0;
/*------
* new style:
* <tcp|unix>:postgresql://server[:port|:/unixsocket/path:]
- * [/db name][?options]
+ * [/db-name][?options]
*------
*/
offset += strlen("postgresql://");
}
else
{
- host = ecpg_strdup(dbname + offset, lineno);
- connect_params++;
+ if (*(dbname + offset) != '\0')
+ {
+ host = ecpg_strdup(dbname + offset, lineno);
+ connect_params++;
+ }
}
}