From: John Darrington Date: Sat, 5 Jan 2013 15:49:53 +0000 (+0100) Subject: Gnumeric reader: Avoid potential crash reading invalid gnumeric files X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;h=36c952154fd4ab874e6ca861a69dfad8177ec065;p=pspp Gnumeric reader: Avoid potential crash reading invalid gnumeric files --- diff --git a/src/data/gnumeric-reader.c b/src/data/gnumeric-reader.c index a1a7415ca1..1904dabc12 100644 --- a/src/data/gnumeric-reader.c +++ b/src/data/gnumeric-reader.c @@ -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 ) {