Skip to content

Commit

Permalink
Fix a pkg memory leak: when parsing of the Contact fails, free
Browse files Browse the repository at this point in the history
all associated parameters that have been parsed so far, not just
the contact structure itself. Reported by OSS-Fuzz.
  • Loading branch information
sobomax committed Mar 14, 2023
1 parent 7c0bdc9 commit e1c60a1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions parser/contact/contact.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,13 @@ int parse_contacts(str* _s, contact_t** _c)
}

error:
if (c) pkg_free(c);
if (c) free_contacts(&c);
free_contacts(_c); /* Free any contacts created so far */
return -1;

ok:
c->len = _s->s - c->name.s;
if (last) {last->next=c;} else {*_c = c;}
last = c;
return 0;
}

Expand Down

0 comments on commit e1c60a1

Please sign in to comment.