Do not assume that canonicalize_file_name() always returns non-null.
[pspp-builds.git] / src / language / utilities / include.c
index 26c718a42de419ada022a35cb07b199dc2fd7406..f3c87779787188ad986e2be99cdb16d335c9354f 100644 (file)
@@ -16,8 +16,9 @@
 
 #include <config.h>
 #include <ctype.h>
+#include <errno.h>
 #include <stdlib.h>
-#include <libpspp/alloc.h>
+#include <string.h>
 #include <language/command.h>
 #include <libpspp/message.h>
 #include <libpspp/getl.h>
 #include <language/lexer/lexer.h>
 #include <libpspp/str.h>
 #include <data/file-name.h>
-#include <dirname.h>
-#include <canonicalize.h>
 
+#include "dirname.h"
+#include "canonicalize.h"
+#include "xalloc.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -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;