[gnumeric] Fix crash on corrupted files. [#702409]



commit 28bf105b0642d7881826b178340a91fff9ca9097
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Sun Jun 16 12:48:52 2013 -0600

    Fix crash on corrupted files. [#702409]
    
    2013-06-16  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (oo_parse_border): check for NULL color

 NEWS                                 |    2 +-
 plugins/openoffice/ChangeLog         |    4 +++
 plugins/openoffice/openoffice-read.c |   50 +++++++++++++++++----------------
 3 files changed, 31 insertions(+), 25 deletions(-)
---
diff --git a/NEWS b/NEWS
index 5a4aaa1..50dc584 100644
--- a/NEWS
+++ b/NEWS
@@ -24,7 +24,7 @@ Andreas:
        * Fix ODF crash. [#702197]
        * In ODF import ignored mentioned but not included sheets. [#698388]
        * Fix crash on corrupted files.  [#702205] [#702219] [#702285]
-         [#702288] [#702322] [#702364]
+         [#702288] [#702322] [#702364] [#702409]
        * Some documentation improvements. [Debian #621735] [Debian #530462] 
 
 Darrell Tangman:
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 9cc2f98..37e9501 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,7 @@
+2013-06-16  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * openoffice-read.c (oo_parse_border): check for NULL color
+
 2013-06-15  Andreas J. Guelzow <aguelzow pyrshep ca>
 
        * openoffice-read.c (odf_destroy_object_offset): new
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index dbd8287..9f142bf 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -6034,31 +6034,33 @@ oo_parse_border (GsfXMLIn *xin, GnmStyle *style,
                char *border_type = g_strndup (end, border_color - end);
                color = oo_parse_color (xin, CC2XML (border_color), "color");
 
-               if (g_str_has_prefix (border_type, "none")||
-                   g_str_has_prefix (border_type, "hidden"))
-                       border_style = GNM_STYLE_BORDER_NONE;
-               else if (g_str_has_prefix (border_type, "solid") ||
-                        g_str_has_prefix (border_type, "groove") ||
-                        g_str_has_prefix (border_type, "ridge") ||
-                        g_str_has_prefix (border_type, "inset") ||
-                        g_str_has_prefix (border_type, "outset")) {
-                       if (pts <= OD_BORDER_THIN)
-                               border_style = GNM_STYLE_BORDER_THIN;
-                       else if (pts <= OD_BORDER_MEDIUM)
-                               border_style = GNM_STYLE_BORDER_MEDIUM;
+               if (color) {
+                       if (g_str_has_prefix (border_type, "none")||
+                           g_str_has_prefix (border_type, "hidden"))
+                               border_style = GNM_STYLE_BORDER_NONE;
+                       else if (g_str_has_prefix (border_type, "solid") ||
+                                g_str_has_prefix (border_type, "groove") ||
+                                g_str_has_prefix (border_type, "ridge") ||
+                                g_str_has_prefix (border_type, "inset") ||
+                                g_str_has_prefix (border_type, "outset")) {
+                               if (pts <= OD_BORDER_THIN)
+                                       border_style = GNM_STYLE_BORDER_THIN;
+                               else if (pts <= OD_BORDER_MEDIUM)
+                                       border_style = GNM_STYLE_BORDER_MEDIUM;
+                               else
+                                       border_style = GNM_STYLE_BORDER_THICK;
+                       } else if (g_str_has_prefix (border_type, "dashed"))
+                               border_style = GNM_STYLE_BORDER_DASHED;
+                       else if (g_str_has_prefix (border_type, "dotted"))
+                               border_style = GNM_STYLE_BORDER_DOTTED;
                        else
-                               border_style = GNM_STYLE_BORDER_THICK;
-               } else if (g_str_has_prefix (border_type, "dashed"))
-                       border_style = GNM_STYLE_BORDER_DASHED;
-               else if (g_str_has_prefix (border_type, "dotted"))
-                       border_style = GNM_STYLE_BORDER_DOTTED;
-               else
-                       border_style = GNM_STYLE_BORDER_DOUBLE;
-
-               border = gnm_style_border_fetch (border_style, color,
-                                                gnm_style_border_get_orientation (loc));
-               border->width = pts;
-               gnm_style_set_border (style, location, border);
+                               border_style = GNM_STYLE_BORDER_DOUBLE;
+                       
+                       border = gnm_style_border_fetch (border_style, color,
+                                                        gnm_style_border_get_orientation (loc));
+                       border->width = pts;
+                       gnm_style_set_border (style, location, border);
+               }
                g_free (border_type);
        }
 }


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