Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit PR/56147: Miroslav Lichvar: Avoid memory leak if...



details:   https://anonhg.NetBSD.org/src/rev/b890baa13dfb
branches:  trunk
changeset: 983144:b890baa13dfb
user:      christos <christos%NetBSD.org@localhost>
date:      Wed May 05 14:49:59 2021 +0000

description:
PR/56147: Miroslav Lichvar: Avoid memory leak if strdup fails.

diffstat:

 lib/libedit/filecomplete.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (35 lines):

diff -r aefd40cee8b6 -r b890baa13dfb lib/libedit/filecomplete.c
--- a/lib/libedit/filecomplete.c        Wed May 05 12:47:02 2021 +0000
+++ b/lib/libedit/filecomplete.c        Wed May 05 14:49:59 2021 +0000
@@ -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 @@
                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 @@
        }
 
        /* free elements of array and the array itself */
+out2:
        for (i = 0; matches[i]; i++)
                el_free(matches[i]);
        el_free(matches);



Home | Main Index | Thread Index | Old Index