Skip to content

Commit

Permalink
alternatives: fix all the leaks of groups in readConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
lnykryn authored and jamacku committed May 14, 2024
1 parent dbb9366 commit 3842524
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion alternatives.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ static int readConfig(struct alternativeSet *set, const char *title,
if (((i = readlink(leader_path, linkBuf, sizeof(linkBuf) - 1)) < 0)) {
fprintf(stderr, _("failed to read link %s: %s\n"),
set->alts[0].leader.facility, strerror(errno));
return 2;
r = 2;
goto finish;
}

linkBuf[i] = '\0';
Expand All @@ -506,6 +507,11 @@ static int readConfig(struct alternativeSet *set, const char *title,

set->currentLink = strdup(normalize_path(linkBuf));
finish:
for (i = 1; i < numGroups; i++) {
free(groups[i].title);
free(groups[i].facility);
}
free(groups);
free(line);
return r;
}
Expand Down

0 comments on commit 3842524

Please sign in to comment.