summaryrefslogtreecommitdiff
path: root/test/user-font-mask.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-03-22 19:02:27 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2009-03-24 07:50:58 +0000
commitac30ced6135c5cf0fb34a67fe8f863030c1fbeb9 (patch)
treef1c3a946653cd5e6bd16c64b7f078ff97e5dcf4f /test/user-font-mask.c
parentb5a4a2c4b1b1bab25e2ff0842e3c27205ec73d51 (diff)
downloadcairo-ac30ced6135c5cf0fb34a67fe8f863030c1fbeb9.tar.gz
[test] Check for surface create failure.
If the image surface creation fails, the data pointer will be NULL leading to a segfault -- so check!
Diffstat (limited to 'test/user-font-mask.c')
-rw-r--r--test/user-font-mask.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/user-font-mask.c b/test/user-font-mask.c
index 149f8ee9e..6fd40c875 100644
--- a/test/user-font-mask.c
+++ b/test/user-font-mask.c
@@ -117,6 +117,9 @@ test_scaled_font_render_glyph (cairo_scaled_font_t *scaled_font,
metrics->x_advance = (glyphs[glyph].width + 1) / 8.0;
image = cairo_image_surface_create (CAIRO_FORMAT_A1, glyphs[glyph].width, 8);
+ if (cairo_surface_status (image))
+ return cairo_surface_status (image);
+
data = cairo_image_surface_get_data (image);
for (i = 0; i < 8; i++) {
byte = glyphs[glyph].data[i];
@@ -125,15 +128,17 @@ test_scaled_font_render_glyph (cairo_scaled_font_t *scaled_font,
}
pattern = cairo_pattern_create_for_surface (image);
+ cairo_surface_destroy (image);
+
cairo_matrix_init_identity (&matrix);
cairo_matrix_scale (&matrix, 1.0/8.0, 1.0/8.0);
cairo_matrix_translate (&matrix, 0, -8);
cairo_matrix_invert (&matrix);
cairo_pattern_set_matrix (pattern, &matrix);
+
cairo_set_source (cr, pattern);
cairo_mask (cr, pattern);
cairo_pattern_destroy (pattern);
- cairo_surface_destroy (image);
return CAIRO_STATUS_SUCCESS;
}