From: tb Date: Tue, 28 Mar 2023 21:33:21 +0000 (+0000) Subject: mg: fix parsing of tag files with duplicate entries X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=35caa2dba38f0d52c0a7c74a57b509cd0ddf0fa9;p=openbsd mg: fix parsing of tag files with duplicate entries Instead of erroring out ignore duplicates. Fixes using /var/db/libc.tags again. ok op --- 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);