From 96243a6c4e43ad7e105b092eea2d7d80163b0d3d Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Mon, 13 Jul 2015 17:13:11 +0200 Subject: [PATCH] ioconf.c: Fix several ressource leaks Some pointers were sometimes not freed, resulting in ressource leaks. This patch fixes that. CID #29711 #29712 #29713. Signed-off-by: Sebastien GODARD --- ioconf.c | 12 ++++++++++++ ioconf.h | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ioconf.c b/ioconf.c index 7d88c5d..846b12e 100644 --- a/ioconf.c +++ b/ioconf.c @@ -354,6 +354,18 @@ int ioc_init(void) ioc_parsed = 1; return (count); + +free_and_return: + /* Free pointers and return */ + fclose(fp); + if (blkp) { + free(blkp); + } + if (iocp) { + free(iocp); + } + + return 0; } /* diff --git a/ioconf.h b/ioconf.h index 1509df9..0d74555 100644 --- a/ioconf.h +++ b/ioconf.h @@ -35,7 +35,7 @@ if (P == NULL) { \ perror("malloc"); \ ioc_free(); \ - return 0; \ + goto free_and_return; \ } \ } \ } \ -- 2.40.0