[gnumeric] StfParse: fix crash.



commit 89bae307f789da4d3c1b56240f6dab797aac3dd7
Author: Morten Welinder <terra gnome org>
Date:   Sat Dec 23 20:19:49 2017 -0500

    StfParse: fix crash.
    
    Ugh.  Not good.

 ChangeLog       |    4 ++++
 NEWS            |    1 +
 src/stf-parse.c |    8 ++++++--
 3 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3171977..993e8a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-12-23  Morten Welinder  <terra gnome org>
+
+       * src/stf-parse.c (stf_parse_sheet): Fix crash on text important.
+
 2017-12-04  Morten Welinder  <terra gnome org>
 
        * src/ssdiff.c (GnmDiffState): Store old_sheet and new_sheet here
diff --git a/NEWS b/NEWS
index e300b00..a067464 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Morten:
        * Teach ssdiff about column/row sizes.
        * Teach ssdiff about defined names.
        * Fix a few ssdiff crashes.
+       * Fix crash on text import.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.37
diff --git a/src/stf-parse.c b/src/stf-parse.c
index 2d4d010..44c1339 100644
--- a/src/stf-parse.c
+++ b/src/stf-parse.c
@@ -1298,6 +1298,7 @@ stf_parse_sheet (StfParseOptions_t *parseoptions,
        gboolean result = TRUE;
        int col;
        unsigned int lcol;
+       size_t nformats;
 
        SETUP_LOCALE_SWITCH;
 
@@ -1314,7 +1315,8 @@ stf_parse_sheet (StfParseOptions_t *parseoptions,
                result = FALSE;
 
        col = start_col;
-       for (lcol = 0; lcol < parseoptions->formats->len; lcol++) {
+       nformats = parseoptions->formats->len;
+       for (lcol = 0; lcol < nformats; lcol++) {
                GOFormat const *fmt = g_ptr_array_index (parseoptions->formats, lcol);
                GnmStyle *mstyle;
                gboolean want_col =
@@ -1358,7 +1360,9 @@ stf_parse_sheet (StfParseOptions_t *parseoptions,
                line = g_ptr_array_index (lines, lrow);
 
                for (lcol = 0; lcol < line->len; lcol++) {
-                       GOFormat const *fmt = g_ptr_array_index (parseoptions->formats, lcol);
+                       GOFormat const *fmt = lcol < nformats
+                               ? g_ptr_array_index (parseoptions->formats, lcol)
+                               : go_format_general ();
                        char const *text = g_ptr_array_index (line, lcol);
                        gboolean want_col =
                                (parseoptions->col_import_array == NULL ||


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]