[pacman-dev] [PATCH 4/4] Move NULL check before dereference

Silvan Jegen s.jegen at gmail.com
Tue Jan 28 11:50:45 EST 2014


Signed-off-by: Silvan Jegen <s.jegen at gmail.com>
---
 src/pacman/pacman.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 7329f0f..1d821ef 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -262,13 +262,13 @@ static void setuseragent(void)
 static void cleanup(int ret)
 {
 	/* free alpm library resources */
-	if(config->handle && alpm_release(config->handle) == -1) {
-		pm_printf(ALPM_LOG_ERROR, "error releasing alpm library\n");
-	}
-
-	/* free memory */
-	FREELIST(pm_targets);
 	if(config) {
+		if(config->handle && alpm_release(config->handle) == -1) {
+			pm_printf(ALPM_LOG_ERROR, "error releasing alpm library\n");
+		}
+
+		/* free memory */
+		FREELIST(pm_targets);
 		config_free(config);
 		config = NULL;
 	}
-- 
1.8.5.3



More information about the pacman-dev mailing list