diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-02-11 16:41:58 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-02-11 16:41:58 +0100 |
commit | de34229c6d0470a1f54aafffb778d72c2e5d9c39 (patch) | |
tree | f5170a88b384bcbc45b6f7118853ecffd6b0d152 | |
parent | f1a91551990bc81e4179d48256bf14252bad7d0d (diff) | |
download | gnunet-de34229c6d0470a1f54aafffb778d72c2e5d9c39.tar.gz gnunet-de34229c6d0470a1f54aafffb778d72c2e5d9c39.zip |
fix use-after-free in postgres error message
-rw-r--r-- | src/postgres/postgres.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/postgres/postgres.c b/src/postgres/postgres.c index 4798c129d..14095c5a4 100644 --- a/src/postgres/postgres.c +++ b/src/postgres/postgres.c | |||
@@ -182,22 +182,22 @@ GNUNET_POSTGRES_connect (const struct GNUNET_CONFIGURATION_Handle * cfg, | |||
182 | &conninfo)) | 182 | &conninfo)) |
183 | conninfo = NULL; | 183 | conninfo = NULL; |
184 | dbh = PQconnectdb (conninfo == NULL ? "" : conninfo); | 184 | dbh = PQconnectdb (conninfo == NULL ? "" : conninfo); |
185 | GNUNET_free_non_null (conninfo); | 185 | |
186 | if (NULL == dbh) | 186 | if (NULL != dbh) |
187 | { | ||
188 | /* FIXME: warn about out-of-memory? */ | ||
189 | return NULL; | ||
190 | } | ||
191 | if (PQstatus (dbh) != CONNECTION_OK) | ||
192 | { | 187 | { |
193 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 188 | if (PQstatus (dbh) != CONNECTION_OK) |
194 | "postgres", | 189 | { |
195 | _("Unable to connect to Postgres database '%s': %s\n"), | 190 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, |
196 | conninfo, | 191 | "postgres", |
197 | PQerrorMessage (dbh)); | 192 | _("Unable to connect to Postgres database '%s': %s\n"), |
198 | PQfinish (dbh); | 193 | conninfo, |
199 | return NULL; | 194 | PQerrorMessage (dbh)); |
195 | PQfinish (dbh); | ||
196 | dbh = NULL; | ||
197 | } | ||
200 | } | 198 | } |
199 | // FIXME: warn about out-of-memory when dbh is NULL? | ||
200 | GNUNET_free_non_null (conninfo); | ||
201 | return dbh; | 201 | return dbh; |
202 | } | 202 | } |
203 | 203 | ||