diff options
author | JP Rosevear <jpr@ximian.com> | 2003-04-19 03:45:27 +0800 |
---|---|---|
committer | Mike Kestner <mkestner@src.gnome.org> | 2003-04-19 03:45:27 +0800 |
commit | 0407034071219444fc151d6d6d52fbc71b98f1b3 (patch) | |
tree | 431009afa6ae8aa3ed0468b51a0645fd3bd7aff1 /widgets/table/e-table-subset.c | |
parent | 57e78e93b5c63416487d18a9ab6245d2028e83a4 (diff) | |
download | gsoc2013-evolution-0407034071219444fc151d6d6d52fbc71b98f1b3.tar.gz gsoc2013-evolution-0407034071219444fc151d6d6d52fbc71b98f1b3.tar.zst gsoc2013-evolution-0407034071219444fc151d6d6d52fbc71b98f1b3.zip |
add guarding for row indexing (Bug# 41497)
2003-04-17 JP Rosevear <jpr@ximian.com>
* e-table-subset.c : add guarding for row indexing (Bug# 41497)
svn path=/trunk/; revision=20891
Diffstat (limited to 'widgets/table/e-table-subset.c')
-rw-r--r-- | widgets/table/e-table-subset.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/widgets/table/e-table-subset.c b/widgets/table/e-table-subset.c index d4a2415f13..a237ba2d94 100644 --- a/widgets/table/e-table-subset.c +++ b/widgets/table/e-table-subset.c @@ -41,6 +41,9 @@ static ETableModelClass *etss_parent_class; #define ETSS_CLASS(object) (E_TABLE_SUBSET_GET_CLASS(object)) +#define VALID_ROW(etss, row) (row >= -1 && row < etss->n_map) +#define MAP_ROW(etss, row) (row == -1 ? -1 : etss->map_table[row]) + static gint etss_get_view_row (ETableSubset *etss, int row) { @@ -144,9 +147,11 @@ etss_value_at (ETableModel *etm, int col, int row) { ETableSubset *etss = (ETableSubset *)etm; + g_return_val_if_fail (VALID_ROW (etss, row), NULL); + etss->last_access = row; d(g_print("g) Setting last_access to %d\n", row)); - return e_table_model_value_at (etss->source, col, etss->map_table [row]); + return e_table_model_value_at (etss->source, col, MAP_ROW(etss, row)); } static void @@ -154,9 +159,11 @@ etss_set_value_at (ETableModel *etm, int col, int row, const void *val) { ETableSubset *etss = (ETableSubset *)etm; + g_return_if_fail (VALID_ROW (etss, row)); + etss->last_access = row; d(g_print("h) Setting last_access to %d\n", row)); - e_table_model_set_value_at (etss->source, col, etss->map_table [row], val); + e_table_model_set_value_at (etss->source, col, MAP_ROW(etss, row), val); } static gboolean @@ -164,7 +171,9 @@ etss_is_cell_editable (ETableModel *etm, int col, int row) { ETableSubset *etss = (ETableSubset *)etm; - return e_table_model_is_cell_editable (etss->source, col, etss->map_table [row]); + g_return_val_if_fail (VALID_ROW (etss, row), FALSE); + + return e_table_model_is_cell_editable (etss->source, col, MAP_ROW(etss, row)); } static gboolean @@ -178,10 +187,12 @@ etss_get_save_id (ETableModel *etm, int row) { ETableSubset *etss = (ETableSubset *)etm; + g_return_val_if_fail (VALID_ROW (etss, row), NULL); + if (e_table_model_has_save_id (etss->source)) - return e_table_model_get_save_id (etss->source, etss->map_table [row]); + return e_table_model_get_save_id (etss->source, MAP_ROW(etss, row)); else - return g_strdup_printf ("%d", etss->map_table[row]); + return g_strdup_printf ("%d", MAP_ROW(etss, row)); } static void |