summaryrefslogtreecommitdiff
path: root/test/user-font-rescale.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-07-22 18:32:47 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-07-24 10:44:03 +0100
commite98e2690cb4ac475819394334cb5e61a8e3d5557 (patch)
tree3077a789acaf0018dc776e6fd5837aca5b3469d9 /test/user-font-rescale.c
parent596dec95610ef02d86ede94eca5b83221b0b533a (diff)
downloadcairo-e98e2690cb4ac475819394334cb5e61a8e3d5557.tar.gz
[test] Fix use of uninitialized widths.
user-font-rescale copied unitialized values from the widths array into the desired array. Although these corresponded to unused glyphs and so were never used during the rendering, the values may have been illegal causing FPE as they were copied.
Diffstat (limited to 'test/user-font-rescale.c')
-rw-r--r--test/user-font-rescale.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/test/user-font-rescale.c b/test/user-font-rescale.c
index ae56ef849..54b3a20ca 100644
--- a/test/user-font-rescale.c
+++ b/test/user-font-rescale.c
@@ -257,11 +257,11 @@ get_user_font_face (cairo_font_face_t *substitute_font,
text, -1,
&glyphs, &num_glyphs,
NULL, NULL, NULL);
- if (status) {
- cairo_font_options_destroy (options);
- cairo_scaled_font_destroy (measure);
+ cairo_font_options_destroy (options);
+ cairo_scaled_font_destroy (measure);
+
+ if (status)
return status;
- }
/* find the glyph range the text covers */
max_index = glyphs[0].index;
@@ -274,7 +274,7 @@ get_user_font_face (cairo_font_face_t *substitute_font,
}
count = max_index - min_index + 1;
- widths = xmalloc (sizeof(double) * count);
+ widths = xcalloc (sizeof (double), count);
/* measure all of the necessary glyphs individually */
for (i=0; i<num_glyphs; i++) {
cairo_text_extents_t extents;
@@ -284,9 +284,6 @@ get_user_font_face (cairo_font_face_t *substitute_font,
cairo_glyph_free (glyphs);
- cairo_font_options_destroy (options);
- cairo_scaled_font_destroy (measure);
-
status = create_rescaled_font (substitute_font,
min_index, count, widths,
out);