summaryrefslogtreecommitdiff
path: root/lib/libedit
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2021-05-05 14:49:59 +0000
committerchristos <christos@NetBSD.org>2021-05-05 14:49:59 +0000
commitc9d074861d3a47bd02e8af9acefa72e4dcece2ce (patch)
treee6129a8c8504bd4292665ecf6e45b249a0a47e12 /lib/libedit
parent5c6d87d8e8b02d98321dd73a1ed6ed377cab776d (diff)
PR/56147: Miroslav Lichvar: Avoid memory leak if strdup fails.
Diffstat (limited to 'lib/libedit')
-rw-r--r--lib/libedit/filecomplete.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libedit/filecomplete.c b/lib/libedit/filecomplete.c
index 963a73fc832..9cdb5481bf8 100644
--- a/lib/libedit/filecomplete.c
+++ b/lib/libedit/filecomplete.c
@@ -1,4 +1,4 @@
-/* $NetBSD: filecomplete.c,v 1.67 2021/03/28 13:39:39 christos Exp $ */
+/* $NetBSD: filecomplete.c,v 1.68 2021/05/05 14:49:59 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: filecomplete.c,v 1.67 2021/03/28 13:39:39 christos Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.68 2021/05/05 14:49:59 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -727,7 +727,7 @@ fn_complete2(EditLine *el,
else
completion = strdup(matches[0]);
if (completion == NULL)
- goto out;
+ goto out2;
/*
* Replace the completed string with the common part of
@@ -810,6 +810,7 @@ fn_complete2(EditLine *el,
}
/* free elements of array and the array itself */
+out2:
for (i = 0; matches[i]; i++)
el_free(matches[i]);
el_free(matches);