Commit d6fb5dcb authored by Michael Vrable's avatar Michael Vrable Committed by Carlos Garcia Campos

Fix a crash in the cairo backend with Type 3 glyphs

Commit 86b7e8a3 ("Ensure cairo renders Type 3 glyphs with only the fill
color") introduced a bug into the Cairo backend, causing evince to crash
with the message
    evince: cairo-pattern.c:679: cairo_pattern_destroy: Assertion
    `((*&(&pattern->ref_count)->ref_count) > 0)' failed.
Fix this by updating reference counts to the fill and stroke patterns when
modifying them in beginType3Char.

Simplify the code as well by not saving the old stroke pattern before
overriding it; this is already done since beginType3Char/endType3Char is
wrapped by calls to saveState/restoreState in Gfx::doShowText.
parent c3a00c83
......@@ -616,13 +616,13 @@ GBool CairoOutputDev::beginType3Char(GfxState *state, double x, double y,
cairo_set_matrix(cairo_shape, &orig_matrix);
cairo_transform(cairo_shape, &matrix);
}
old_stroke_pattern = stroke_pattern;
cairo_pattern_destroy(stroke_pattern);
cairo_pattern_reference(fill_pattern);
stroke_pattern = fill_pattern;
return gFalse;
}
void CairoOutputDev::endType3Char(GfxState *state) {
stroke_pattern = old_stroke_pattern;
cairo_restore (cairo);
if (cairo_shape) {
cairo_restore (cairo_shape);
......
......@@ -199,7 +199,7 @@ protected:
void doPath(cairo_t *cairo, GfxState *state, GfxPath *path);
GfxRGB fill_color, stroke_color;
cairo_pattern_t *fill_pattern, *stroke_pattern, *old_stroke_pattern;
cairo_pattern_t *fill_pattern, *stroke_pattern;
double fill_opacity;
double stroke_opacity;
CairoFont *currentFont;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment