PR/48876: Dmitriy Grigoryev: Core dump in readline lib on attempted expansion

Make sure we have 2 matches before calling strcmp().
This commit is contained in:
christos 2014-06-05 22:07:42 +00:00
parent 78d38aa25c
commit 78dc8159da

View File

@ -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