Avoid crash when importing non-existant spreadsheet file
authorJohn Darrington <john@darrington.wattle.id.au>
Mon, 25 Feb 2013 10:15:56 +0000 (11:15 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Mon, 25 Feb 2013 10:15:56 +0000 (11:15 +0100)
src/language/data-io/get-data.c

index cfa33d115239010244e082705d45e2bd1b885df1..f243aecac3f4014acc69a97b16df93310ae61d64 100644 (file)
@@ -1,5 +1,6 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012,
+                 2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -88,12 +89,16 @@ cmd_get_data (struct lexer *lexer, struct dataset *ds)
       if ( 0 == strncasecmp (tok, "GNM", 3))
        {
          struct spreadsheet *spreadsheet = gnumeric_probe (filename, true);
+         if (spreadsheet == NULL)
+           goto error;
          reader = gnumeric_make_reader (spreadsheet, &opts);
          dict = spreadsheet->dict;
        }
       else if (0 == strncasecmp (tok, "ODS", 3))
        {
          struct spreadsheet *spreadsheet = ods_probe (filename, true);
+         if (spreadsheet == NULL)
+           goto error;
          reader = ods_make_reader (spreadsheet, &opts);
          dict = spreadsheet->dict;
        }