[goffice] Fix crash when loading an invalid graph with a custom theme. [#702887]



commit 24e024bd5a8d37d3ff3012481eb08b0ced071086
Author: Jean Brefort <jean brefort normalesup org>
Date:   Mon Jun 24 13:49:36 2013 +0200

    Fix crash when loading an invalid graph with a custom theme. [#702887]

 ChangeLog                 |    8 ++++++++
 NEWS                      |    1 +
 goffice/graph/gog-graph.c |    3 +++
 goffice/graph/gog-theme.c |   13 +++++++++----
 4 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 70e93f8..42af08e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2013-06-24  Jean Brefort  <jean brefort normalesup org>
+
+       * goffice/graph/gog-graph.c (gog_graph_finalize): destroy all sources.
+       [#702887]
+       * goffice/graph/gog-theme.c (gog_theme_get_color_map),
+       (gog_theme_set_name), (gog_theme_set_description), (gog_theme_dup),
+       (gog_theme_edit): check the argument type.
+
 2013-06-22  Jean Brefort  <jean brefort normalesup org>
 
        * goffice/graph/gog-label.c (gog_text_view_natural_size),
diff --git a/NEWS b/NEWS
index 9b62a67..147d5d2 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Jean:
        * Allow regression equation frame to rotate with text. [#701546]
        * New matrix plots. [#657918][#680806]
        * Set a minimal size for the graph property box. [#699473]
+       * Fix crash when loading an invalid graph with a custom theme. [#702887]
 
 Morten:
        * Fix issue with librsvg includes.  [#695167]
diff --git a/goffice/graph/gog-graph.c b/goffice/graph/gog-graph.c
index 54d6ea4..2958472 100644
--- a/goffice/graph/gog-graph.c
+++ b/goffice/graph/gog-graph.c
@@ -244,6 +244,9 @@ gog_graph_finalize (GObject *obj)
 
        g_hash_table_unref (graph->data_refs);
 
+       /* remove timers and other idles, see #702887 */
+       while (g_source_remove_by_user_data (graph));
+
        (graph_parent_klass->finalize) (obj);
 }
 
diff --git a/goffice/graph/gog-theme.c b/goffice/graph/gog-theme.c
index 06b009e..66b6d42 100644
--- a/goffice/graph/gog-theme.c
+++ b/goffice/graph/gog-theme.c
@@ -1705,6 +1705,7 @@ _gog_themes_shutdown (void)
 GogAxisColorMap const *
 gog_theme_get_color_map (GogTheme const *theme, gboolean discrete)
 {
+       g_return_val_if_fail (GOG_IS_THEME (theme), NULL);
        if (discrete)
                return theme->dcm;
        else
@@ -1754,6 +1755,7 @@ gog_theme_foreach (GFunc handler, gpointer user_data)
 static void
 gog_theme_set_name (GogTheme *theme, char const *name)
 {
+       g_return_if_fail (GOG_IS_THEME (theme));
        g_free (theme->name);
        g_hash_table_remove_all (theme->names);
        theme->name = g_strdup (name);
@@ -1762,6 +1764,7 @@ gog_theme_set_name (GogTheme *theme, char const *name)
 static void
 gog_theme_set_description (GogTheme *theme, char const *desc)
 {
+       g_return_if_fail (GOG_IS_THEME (theme));
        g_free (theme->description);
        g_hash_table_remove_all (theme->descs);
        theme->description = g_strdup (desc);
@@ -1778,11 +1781,13 @@ gog_theme_set_description (GogTheme *theme, char const *desc)
 GogTheme*
 gog_theme_dup (GogTheme *theme)
 {
-       GogTheme *new_theme = g_object_new (GOG_TYPE_THEME,
-                                           "resource-type", GO_RESOURCE_RW,
-                                           NULL);
+       GogTheme *new_theme;
        char *desc, *name;
 
+       g_return_val_if_fail (GOG_IS_THEME (theme), NULL);
+       new_theme = g_object_new (GOG_TYPE_THEME,
+                                 "resource-type", GO_RESOURCE_RW,
+                                 NULL);
        new_theme->id = go_uuid ();
        gog_theme_build_uri (new_theme);
        gog_theme_set_name (new_theme, "New theme");
@@ -1841,7 +1846,7 @@ gog_theme_edit (GogTheme *theme, GOCmdContext *cc)
        struct theme_edit_state state;
        GtkWidget *w;
 
-       if (theme == NULL) {
+       if (!GOG_IS_THEME (theme)) {
                /* display a dialog box to select used roles and series number */
                GtkBuilder *gui = go_gtk_builder_load_internal ("res:go:graph/new-theme-prefs.ui", 
GETTEXT_PACKAGE, cc);
                int response;


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