Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit PR/30215: Kouichirou Hiratsuka: /bin/sh dumps co...



details:   https://anonhg.NetBSD.org/src/rev/126c2c7bb4e9
branches:  trunk
changeset: 580868:126c2c7bb4e9
user:      christos <christos%NetBSD.org@localhost>
date:      Thu May 12 15:48:40 2005 +0000

description:
PR/30215: Kouichirou Hiratsuka: /bin/sh dumps core with tabcomplete
Don't core-dump when trying to complete an empty line; instead assume ./

diffstat:

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

diffs (42 lines):

diff -r bb739f08bd35 -r 126c2c7bb4e9 lib/libedit/filecomplete.c
--- a/lib/libedit/filecomplete.c        Thu May 12 15:19:48 2005 +0000
+++ b/lib/libedit/filecomplete.c        Thu May 12 15:48:40 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecomplete.c,v 1.3 2005/05/09 20:10:33 dsl Exp $     */
+/*     $NetBSD: filecomplete.c,v 1.4 2005/05/12 15:48:40 christos Exp $        */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: filecomplete.c,v 1.3 2005/05/09 20:10:33 dsl Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.4 2005/05/12 15:48:40 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -184,12 +184,18 @@
 
                /* support for ``~user'' syntax */
                free(dirpath);
-               if (dirname && *dirname == '~') {
+
+               if (dirname == NULL && (dirname = strdup("./")) == NULL)
+                       return NULL;
+
+               if (*dirname == '~')
                        dirpath = tilde_expand(dirname);
-                       if (dirpath == NULL)
-                               return NULL;
-               } else
-                       dirpath = strdup(dirname ? dirname : "./");
+               else
+                       dirpath = strdup(dirname);
+
+               if (dirpath == NULL)
+                       return NULL;
+
                dir = opendir(dirpath);
                if (!dir)
                        return (NULL);  /* cannot open the directory */



Home | Main Index | Thread Index | Old Index