Avoid crash when attempting to open files with invalid encoding
authorJohn Darrington <john@darrington.wattle.id.au>
Sun, 15 Dec 2013 16:18:41 +0000 (17:18 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Sun, 15 Dec 2013 16:20:23 +0000 (17:20 +0100)
src/ui/gui/psppire-data-window.c

index ca4f21e2219236f07db4bbeb626ad6d9eda59908..a0c4b9645aa62ef27dedadaa4d5b91da67ae7283 100644 (file)
@@ -341,17 +341,19 @@ load_file (PsppireWindow *de, const gchar *file_name, gpointer syn)
     {
       gchar *utf8_file_name;
       struct string filename;
-      ds_init_empty (&filename);
       
       utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, NULL);
-    
+
+      if (NULL == utf8_file_name)
+       return FALSE;
+
+      ds_init_empty (&filename);    
       syntax_gen_string (&filename, ss_cstr (utf8_file_name));
       
       g_free (utf8_file_name);
       
       syntax = g_strdup_printf ("GET FILE=%s.", ds_cstr (&filename));
       ds_destroy (&filename);
-
     }
   else
     {