Fix possible segfault if siglist was empty

If siglist->results wasn't a NULL pointer, we would try to free it
anyway, even if siglist->count was zero. Only attempt to free this
pointer if we had results and the pointer is valid.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-09-21 19:13:43 -05:00
parent 3a460a8be6
commit 5e7875ae6a
1 changed files with 4 additions and 1 deletions

View File

@ -615,7 +615,10 @@ int SYMEXPORT alpm_siglist_cleanup(alpm_siglist_t *siglist)
free(result->key.fingerprint);
}
}
FREE(siglist->results);
if(siglist->count) {
free(siglist->results);
}
siglist->results = NULL;
siglist->count = 0;
return 0;
}