From 35caa2dba38f0d52c0a7c74a57b509cd0ddf0fa9 Mon Sep 17 00:00:00 2001 From: tb Date: Tue, 28 Mar 2023 21:33:21 +0000 Subject: [PATCH] mg: fix parsing of tag files with duplicate entries Instead of erroring out ignore duplicates. Fixes using /var/db/libc.tags again. ok op --- usr.bin/mg/tags.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.bin/mg/tags.c b/usr.bin/mg/tags.c index 0e44c0f971e..41684a863a8 100644 --- a/usr.bin/mg/tags.c +++ b/usr.bin/mg/tags.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tags.c,v 1.23 2023/03/22 22:09:37 op Exp $ */ +/* $OpenBSD: tags.c,v 1.24 2023/03/28 21:33:21 tb Exp $ */ /* * This file is in the public domain. @@ -388,8 +388,10 @@ addctag(char *s) if (*l == '\0') goto cleanup; t->pat = strip(l, strlen(l)); - if (RB_INSERT(tagtree, &tags, t) != NULL) - goto cleanup; + if (RB_INSERT(tagtree, &tags, t) != NULL) { + free(t); + free(s); + } return (TRUE); cleanup: free(t); -- 2.20.1