[evolution] Test whether referenced column exists when loading ETableState



commit 1ae0f96a16ecf3a6e6a2b8f790578f7726066c36
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jun 28 12:39:36 2019 +0200

    Test whether referenced column exists when loading ETableState
    
    This could lead to a crash as here:
    https://bugzilla.gnome.org/show_bug.cgi?id=675286#c1

 src/e-util/e-table-state.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/e-util/e-table-state.c b/src/e-util/e-table-state.c
index 98a429725c..2a3438f905 100644
--- a/src/e-util/e-table-state.c
+++ b/src/e-util/e-table-state.c
@@ -528,9 +528,13 @@ e_table_state_load_from_node (ETableState *state,
        for (; children; children = children->next) {
                if (!strcmp ((gchar *) children->name, "column")) {
                        int_and_double *column_info = g_new (int_and_double, 1);
+                       gint column_source;
 
-                       column_info->column = e_xml_get_integer_prop_by_name (
-                               children, (const guchar *)"source");
+                       column_source = e_xml_get_integer_prop_by_name (children, (const guchar *) "source");
+                       if (column_source < 0 || column_source >= columns->len)
+                               continue;
+
+                       column_info->column = column_source;
                        column_info->expansion =
                                e_xml_get_double_prop_by_name_with_default (
                                        children, (const guchar *)"expansion", 1);


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