Move NULL check before dereference

Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Silvan Jegen 2014-01-28 18:58:52 +01:00 committed by Allan McRae
parent 77da9dc974
commit 819b4cd54e

View file

@ -261,18 +261,18 @@ static void setuseragent(void)
*/ */
static void cleanup(int ret) 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) {
/* free alpm library resources */
if(config->handle && alpm_release(config->handle) == -1) {
pm_printf(ALPM_LOG_ERROR, "error releasing alpm library\n");
}
config_free(config); config_free(config);
config = NULL; config = NULL;
} }
/* free memory */
FREELIST(pm_targets);
exit(ret); exit(ret);
} }