diff options
author | Jose M. Guisado <jguisado@soleta.eu> | 2021-06-01 13:28:37 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2021-06-01 14:14:15 +0200 |
commit | cb7fa569b2f79e8c767b3969394839a96f241298 (patch) | |
tree | a75c993fa2443e4989bd0d90808302e1b917d352 /src/dbi.c | |
parent | 41fad11408daf3769ff1774390357caf6dd50a25 (diff) |
#941 Free dbi_inst when og_dbi_open fails to connect
When trying to open a connection to a database, an instance of
libdbi is created before any connection attempt. If connection is
unsuccessful then the og_dbi struct is freed but not the
libdbi instance member, thus leaking its memory.
Use libdbi dbi_shutdown_r to shutdown libdbi instance member
before freeing og_dbi struct inside og_dbi_open.
Diffstat (limited to 'src/dbi.c')
-rw-r--r-- | src/dbi.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -39,6 +39,7 @@ struct og_dbi *og_dbi_open(struct og_dbi_config *config) dbi_conn_set_option(dbi->conn, "encoding", "UTF-8"); if (dbi_conn_connect(dbi->conn) < 0) { + dbi_shutdown_r(dbi->inst); free(dbi); return NULL; } |