Module Name: src
Committed By: christos
Date: Thu Jun 5 22:07:42 UTC 2014
Modified Files:
src/lib/libedit: filecomplete.c
Log Message:
PR/48876: Dmitriy Grigoryev: Core dump in readline lib on attempted expansion
Make sure we have 2 matches before calling strcmp().
To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libedit/filecomplete.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libedit/filecomplete.c
diff -u src/lib/libedit/filecomplete.c:1.31 src/lib/libedit/filecomplete.c:1.32
--- src/lib/libedit/filecomplete.c:1.31 Fri Sep 16 12:13:16 2011
+++ src/lib/libedit/filecomplete.c Thu Jun 5 18:07:42 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: filecomplete.c,v 1.31 2011/09/16 16:13:16 plunky Exp $ */
+/* $NetBSD: filecomplete.c,v 1.32 2014/06/05 22:07:42 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.31 2011/09/16 16:13:16 plunky Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.32 2014/06/05 22:07:42 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -490,7 +490,8 @@ fn_complete(EditLine *el,
if (what_to_do == '?')
goto display_matches;
- if (matches[2] == NULL && strcmp(matches[0], matches[1]) == 0) {
+ if (matches[2] == NULL &&
+ (matches[1] == NULL || strcmp(matches[0], matches[1]) == 0)) {
/*
* We found exact match. Add a space after
* it, unless we do filename completion and the