Gnumeric reader: Avoid potential crash reading invalid gnumeric files 20130106030502/pspp
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 5 Jan 2013 15:49:53 +0000 (16:49 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 5 Jan 2013 15:49:53 +0000 (16:49 +0100)
src/data/gnumeric-reader.c

index a1a7415ca1b5f03097432324567293e9cfb549b4..1904dabc1232275c251ed04153280114e70c1f00 100644 (file)
@@ -299,7 +299,7 @@ gnumeric_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dic
                            (xmlInputCloseCallback) gzclose, gz,
                           NULL, NULL, 0);
 
-  if ( r->xtr == NULL)
+  if ( r->xtr == NULL )
     goto error;
 
   if ( gri->cell_range )
@@ -422,10 +422,13 @@ gnumeric_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dic
        }
     }
 
-
-  /* Create the dictionary and populate it */
-  *dict = r->dict = dict_create (
-    CHAR_CAST (const char *, xmlTextReaderConstEncoding (r->xtr)));
+  {
+    const xmlChar *enc = xmlTextReaderConstEncoding (r->xtr);
+    if ( enc == NULL)
+      goto error;
+    /* Create the dictionary and populate it */
+    *dict = r->dict = dict_create (CHAR_CAST (const char *, enc));
+  }
 
   for (i = 0 ; i < n_var_specs ; ++i )
     {