From 0d99288ed69fa139ac9fbeccb072dc697c1ed740 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 15 Oct 2008 20:39:57 -0700 Subject: [PATCH] Do not assume that canonicalize_file_name() always returns non-null. Fixes bug #24569. --- src/language/utilities/include.c | 9 +++++++++ tests/command/insert.sh | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/language/utilities/include.c b/src/language/utilities/include.c index d7b10283..f3c87779 100644 --- a/src/language/utilities/include.c +++ b/src/language/utilities/include.c @@ -16,7 +16,9 @@ #include #include +#include #include +#include #include #include #include @@ -192,6 +194,13 @@ parse_insert (struct lexer *lexer, char **filename) } *filename = canonicalize_file_name (relative_filename); + if (*filename == NULL) + { + msg (SE, _("Unable to open `%s': %s."), + relative_filename, strerror (errno)); + free (relative_filename); + return CMD_FAILURE; + } free (relative_filename); return CMD_SUCCESS; diff --git a/tests/command/insert.sh b/tests/command/insert.sh index 354a54f8..d08c7a71 100755 --- a/tests/command/insert.sh +++ b/tests/command/insert.sh @@ -250,5 +250,23 @@ EOF if [ $? -ne 0 ] ; then fail ; fi +# Test for regression against bug #24569 in which PSPP crashed +# upon attempt to insert a nonexistent file. +activity="create wrapper 9" +cat < $TESTFILE +INSERT + FILE='$TEMPDIR/nonexistent' + ERROR=CONTINUE. + . + +LIST. + +EOF +if [ $? -ne 0 ] ; then no_result ; fi + +#This command should fail +activity="run program 7" +$SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > /dev/null +if [ $? -eq 0 ] ; then no_result ; fi pass; -- 2.30.2