[goffice] Don't try to use NULL data sets, see #702126.



commit 341f3aecfbb25721d90fb1f6aa48fd60560c0532
Author: Jean Brefort <jean brefort normalesup org>
Date:   Thu Jun 13 11:07:14 2013 +0200

    Don't try to use NULL data sets, see #702126.

 ChangeLog                    |    6 ++++++
 goffice/graph/gog-data-set.c |   10 +++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1fbabc1..c35141d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-06-13  Jean Brefort  <jean brefort normalesup org>
+
+       * goffice/graph/gog-data-set.c (gog_dataset_dims),
+       (gog_dataset_get_dim), (gog_dataset_set_dim): protect against a NULL set.
+       (see #702126).
+
 2013-06-10  Jean Brefort  <jean brefort normalesup org>
 
        * plugins/plot_surface/gog-matrix.c (gog_matrix_view_render): ensure that
diff --git a/goffice/graph/gog-data-set.c b/goffice/graph/gog-data-set.c
index 97f7582..c373015 100644
--- a/goffice/graph/gog-data-set.c
+++ b/goffice/graph/gog-data-set.c
@@ -69,7 +69,9 @@ gog_dataset_get_type (void)
 void
 gog_dataset_dims (GogDataset const *set, int *first, int *last)
 {
-       GogDatasetClass *klass = GOG_DATASET_GET_CLASS (set);
+       GogDatasetClass *klass;
+       g_return_if_fail (set);
+       klass = GOG_DATASET_GET_CLASS (set);
        g_return_if_fail (klass != NULL);
        g_return_if_fail (first != NULL);
        g_return_if_fail (last != NULL);
@@ -87,7 +89,9 @@ gog_dataset_dims (GogDataset const *set, int *first, int *last)
 GOData *
 gog_dataset_get_dim (GogDataset const *set, int dim_i)
 {
-       GogDatasetElement *elem = gog_dataset_get_elem (set, dim_i);
+       GogDatasetElement *elem;
+       g_return_val_if_fail (set, NULL);
+       elem = gog_dataset_get_elem (set, dim_i);
        if (NULL == elem)
                return NULL;
        return elem->data;
@@ -108,7 +112,7 @@ gog_dataset_set_dim (GogDataset *set, int dim_i, GOData *val, GError **err)
        GogDatasetClass *klass;
        int first, last;
 
-       g_return_if_fail (val == NULL || GO_IS_DATA (val));
+       g_return_if_fail (set != NULL || val == NULL || GO_IS_DATA (val));
 
        if (set == NULL || !GOG_IS_DATASET (set)) {
                g_warning ("gog_dataset_set_dim called with invalid GogDataset");


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