Do not assume that canonicalize_file_name() always returns non-null.
authorBen Pfaff <blp@gnu.org>
Thu, 16 Oct 2008 03:39:57 +0000 (20:39 -0700)
committerBen Pfaff <blp@gnu.org>
Thu, 16 Oct 2008 03:39:57 +0000 (20:39 -0700)
Fixes bug #24569.

src/language/utilities/include.c
tests/command/insert.sh

index d7b102836e460cf0f05650d201d718b546bb0db5..f3c87779787188ad986e2be99cdb16d335c9354f 100644 (file)
@@ -16,7 +16,9 @@
 
 #include <config.h>
 #include <ctype.h>
+#include <errno.h>
 #include <stdlib.h>
+#include <string.h>
 #include <language/command.h>
 #include <libpspp/message.h>
 #include <libpspp/getl.h>
@@ -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;
index 354a54f898497c8bcdccaf1ec1af8aae6ec0bf8f..d08c7a71edabdc0a24cf7906606cb44df3520f9b 100755 (executable)
@@ -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 <<EOF > $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;