From d6de0ad8d524a943e538c7d34b7872a7ece9b9a1 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 6 Apr 2021 02:04:50 +0200 Subject: Fix memory leak in list-contacts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- list-contacts.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/list-contacts.c b/list-contacts.c index eabce15..090de9f 100644 --- a/list-contacts.c +++ b/list-contacts.c @@ -74,16 +74,16 @@ main(int argc, char *argv[]) eprintf("libcontacts_load_contacts:"); for (i = 0; (contact = contacts[i]); i++) { if (emergency && !contact->in_case_of_emergency) - continue; + goto next; if (include_men && contact->gender == LIBCONTACTS_MALE); else if (include_women && contact->gender == LIBCONTACTS_FEMALE); else if (include_orgs && contact->gender == LIBCONTACTS_NOT_A_PERSON); else if (include_unspec && contact->gender == LIBCONTACTS_UNSPECIFIED_GENDER); else - continue; + goto next; if (service && !contact->blocks) { if (blocked_on) - continue; + goto next; } else if (service) { for (j = 0; contact->blocks[j]; j++) { if (!contact->blocks[j]->service) @@ -94,12 +94,13 @@ main(int argc, char *argv[]) break; } if (!blocked_on == !contact->blocks[j]) - continue; + goto next; } if (names && contact->name) printf("%s (%s)\n", contact->id, contact->name); else printf("%s\n", contact->id); + next: libcontacts_contact_destroy(contact); free(contact); } -- cgit v1.2.3-70-g09d2