[goffice] Don't use invalid patterns. See #702833



commit b8e72bc147d9965d49296b52d27c86d308b11e2f
Author: Jean Brefort <jean brefort normalesup org>
Date:   Sat Jun 22 11:09:13 2013 +0200

    Don't use invalid patterns. See #702833

 ChangeLog                  |    7 +++++++
 goffice/utils/go-pattern.c |    2 ++
 goffice/utils/go-style.c   |    1 +
 3 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f193c8d..36102a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-06-22  Jean Brefort  <jean brefort normalesup org>
+
+       * goffice/utils/go-pattern.c (go_pattern_get_pattern),
+       (go_pattern_create_cairo_pattern): don't use an invalid pattern.
+       [see #702833]
+       * goffice/utils/go-style.c (go_style_set_cairo_line): ditto.
+
 2013-06-18  Jean Brefort  <jean brefort normalesup org>
 
        * goffice/graph/gog-guru.ui: set a minimal size. [#699473]
diff --git a/goffice/utils/go-pattern.c b/goffice/utils/go-pattern.c
index 67f619c..108acb2 100644
--- a/goffice/utils/go-pattern.c
+++ b/goffice/utils/go-pattern.c
@@ -189,6 +189,7 @@ go_pattern_set_solid (GOPattern *pat, GOColor fore)
 guint8 const *
 go_pattern_get_pattern (GOPattern const *pat)
 {
+       g_return_val_if_fail (pat != NULL && pat->pattern < GO_PATTERN_MAX, NULL);
        return go_patterns [pat->pattern].pattern;
 }
 
@@ -271,6 +272,7 @@ go_pattern_create_cairo_pattern (GOPattern const *pattern, cairo_t *cr)
        cairo_pattern_t *cr_pattern;
        GOColor color;
 
+       g_return_val_if_fail (pat != NULL && pat->pattern < GO_PATTERN_MAX, NULL);
        if (go_pattern_is_solid (pattern, &color)) {
                cr_pattern = cairo_pattern_create_rgba (GO_COLOR_TO_CAIRO (color));
 
diff --git a/goffice/utils/go-style.c b/goffice/utils/go-style.c
index 3a2fcea..854b7c4 100644
--- a/goffice/utils/go-style.c
+++ b/goffice/utils/go-style.c
@@ -2149,6 +2149,7 @@ go_style_set_cairo_line (GOStyle const *style, cairo_t *cr)
                pat.back = style->line.color;
                pat.pattern = style->line.pattern;
                cp = go_pattern_create_cairo_pattern (&pat, cr);
+               g_return_val_if_fail (cp != NULL, FALSE);
                cairo_user_to_device_distance (cr, &scalex, &scaley);
                cairo_matrix_init_scale (&mat, scalex, scaley);
                cairo_pattern_set_matrix (cp, &mat);


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