aboutsummaryrefslogtreecommitdiffstats
path: root/list-contacts.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-04-06 02:04:50 +0200
committerMattias Andrée <maandree@kth.se>2021-04-06 02:04:50 +0200
commitd6de0ad8d524a943e538c7d34b7872a7ece9b9a1 (patch)
tree575ea74ddfdb26eb53aaf38ef0bc89ff146b8621 /list-contacts.c
parentUpdate list-contacts to handle block status (diff)
downloadcontacts-d6de0ad8d524a943e538c7d34b7872a7ece9b9a1.tar.gz
contacts-d6de0ad8d524a943e538c7d34b7872a7ece9b9a1.tar.bz2
contacts-d6de0ad8d524a943e538c7d34b7872a7ece9b9a1.tar.xz
Fix memory leak in list-contacts
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--list-contacts.c9
1 files 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);
}