GNOME Bugzilla – Bug 378558
Crash on opening empty text file (Fix attached)
Last modified: 2006-11-24 01:45:01 UTC
This bug is forwarded from ubuntu bug tracking system: https://launchpad.net/distros/ubuntu/+source/gnumeric/+bug/72966 Original description: "I launched Gnumeric accidentally by double clicking on a file called "industries.csv" which is 1 byte long (a newline character, 0x0a). For what it's worth, Gnumeric also crashes when opening (double click in nautilus, use gnome-open, or launch Gnumeric first and choose file->open from the menu) an empty file called "empty.csv" but succeeds on similarly named 1 byte files containing a comma (0x2c) or tab character (0x09). Bug Buddy reports the following error, so I'll just paste the traceback details below..." I fount that giving null to strchr function caused these problems and here's a little one-liner for fixing this. --- src/stf-parse.c.orig 2006-11-23 19:58:39.000000000 +0200 +++ src/stf-parse.c 2006-11-23 20:01:02.000000000 +0200 @@ -1418,10 +1418,12 @@ stf_parse_options_set_type (res, PARSE_TYPE_CSV); stf_parse_options_set_trim_spaces (res, TRIM_TYPE_LEFT | TRIM_TYPE_RIGHT); stf_parse_options_csv_set_indicator_2x_is_single (res, TRUE); - stf_parse_options_csv_set_duplicates - (res, strchr (res->sep.chr, ' ') != NULL); - stf_parse_options_csv_set_trim_seps - (res, strchr (res->sep.chr, ' ') != NULL); + if (res->sep.chr) { + stf_parse_options_csv_set_duplicates + (res, strchr (res->sep.chr, ' ') != NULL); + stf_parse_options_csv_set_trim_seps + (res, strchr (res->sep.chr, ' ') != NULL); + } stf_parse_options_csv_set_stringindicator (res, '"'); } else {
Created attachment 77069 [details] [review] one-liner for fixing this
*** This bug has been marked as a duplicate of 345477 ***