From: Ben Pfaff Date: Thu, 16 Oct 2008 03:39:57 +0000 (-0700) Subject: Do not assume that canonicalize_file_name() always returns non-null. X-Git-Tag: v0.7.1~6^2~6 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d99288ed69fa139ac9fbeccb072dc697c1ed740;p=pspp-builds.git Do not assume that canonicalize_file_name() always returns non-null. Fixes bug #24569. --- 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;