Skip to content

Commit 1adbb34

Browse files
committed
Fix minor bugs in commit 30bf468 et al.
Coverity complained that the "else" added to fillPGconn() was unreachable, which it was. Remove the dead code. In passing, rearrange the tests so as not to bother trying to fetch values for options that can't be assigned. Pre-9.3 did not have that issue, but it did have a "return" that should be "goto oom_error" to ensure that a suitable error message gets filled in.
1 parent 22dfd11 commit 1adbb34

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/interfaces/libpq/fe-connect.c

+6-9
Original file line numberDiff line numberDiff line change
@@ -684,16 +684,16 @@ fillPGconn(PGconn *conn, PQconninfoOption *connOptions)
684684

685685
for (option = PQconninfoOptions; option->keyword; option++)
686686
{
687-
const char *tmp = conninfo_getval(connOptions, option->keyword);
688-
689-
if (tmp && option->connofs >= 0)
687+
if (option->connofs >= 0)
690688
{
691-
char **connmember = (char **) ((char *) conn + option->connofs);
689+
const char *tmp = conninfo_getval(connOptions, option->keyword);
692690

693-
if (*connmember)
694-
free(*connmember);
695691
if (tmp)
696692
{
693+
char **connmember = (char **) ((char *) conn + option->connofs);
694+
695+
if (*connmember)
696+
free(*connmember);
697697
*connmember = strdup(tmp);
698698
if (*connmember == NULL)
699699
{
@@ -702,8 +702,6 @@ fillPGconn(PGconn *conn, PQconninfoOption *connOptions)
702702
return false;
703703
}
704704
}
705-
else
706-
*connmember = NULL;
707705
}
708706
}
709707

@@ -793,7 +791,6 @@ connectOptions2(PGconn *conn)
793791
conn->pgpass = strdup(DefaultPassword);
794792
if (!conn->pgpass)
795793
goto oom_error;
796-
797794
}
798795
else
799796
conn->dot_pgpass_used = true;

0 commit comments

Comments
 (0)