When doing lm_add(), check for duplicates.
This is useful when lm_find() moves the match to the global mapping, since lm_find() could be called with a same path more than once. Reported and tested by: Andreas Longwitz <longwitz@incore.de> Sponsored by: The FreeBSD Foundation Approved by: re (gjb) MFC after: 1 week
This commit is contained in:
parent
ac4031d805
commit
6c30676522
@ -353,6 +353,7 @@ lm_add(const char *p, const char *f, const char *t)
|
||||
{
|
||||
struct lm_list *lml;
|
||||
struct lm *lm;
|
||||
const char *t1;
|
||||
|
||||
if (p == NULL)
|
||||
p = "$DEFAULT$";
|
||||
@ -362,11 +363,14 @@ lm_add(const char *p, const char *f, const char *t)
|
||||
if ((lml = lmp_find(p)) == NULL)
|
||||
lml = lmp_init(xstrdup(p));
|
||||
|
||||
lm = xmalloc(sizeof(struct lm));
|
||||
lm->f = xstrdup(f);
|
||||
lm->t = xstrdup(t);
|
||||
TAILQ_INSERT_HEAD(lml, lm, lm_link);
|
||||
lm_count++;
|
||||
t1 = lml_find(lml, f);
|
||||
if (t1 == NULL || strcmp(t1, t) != 0) {
|
||||
lm = xmalloc(sizeof(struct lm));
|
||||
lm->f = xstrdup(f);
|
||||
lm->t = xstrdup(t);
|
||||
TAILQ_INSERT_HEAD(lml, lm, lm_link);
|
||||
lm_count++;
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
|
Loading…
Reference in New Issue
Block a user