From cb7fa569b2f79e8c767b3969394839a96f241298 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Tue, 1 Jun 2021 13:28:37 +0200 Subject: #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. --- src/dbi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/dbi.c b/src/dbi.c index 234e91e..aaf6c8b 100644 --- a/src/dbi.c +++ b/src/dbi.c @@ -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; } -- cgit v1.2.3-18-g5258