fix memory leak at PangoFontInfo::CanRenderString

This commit is contained in:
zdenop 2019-10-20 16:43:04 +02:00
parent 1ec34378d9
commit 36dc2ccf75

View File

@ -402,12 +402,12 @@ bool PangoFontInfo::CanRenderString(const char* utf8_word, int len,
PangoGlyph dotted_circle_glyph;
PangoFont* font = run->item->analysis.font;
#ifdef _WIN32 // Fixme! Leaks memory and breaks unittests.
#ifdef _WIN32
PangoGlyphString* glyphs = pango_glyph_string_new();
char s[] = "\xc2\xa7";
pango_shape(s, sizeof(s), &(run->item->analysis), glyphs);
const char s[] = "\xc2\xa7";
pango_shape(s, strlen(s), &(run->item->analysis), glyphs);
dotted_circle_glyph = glyphs->glyphs[0].glyph;
#else
#else // TODO: Do we need separate solution for non win build?
dotted_circle_glyph = pango_fc_font_get_glyph(
reinterpret_cast<PangoFcFont*>(font), kDottedCircleGlyph);
#endif
@ -463,6 +463,9 @@ bool PangoFontInfo::CanRenderString(const char* utf8_word, int len,
if (bad_glyph)
tlog(1, "Found illegal glyph!\n");
}
#ifdef _WIN32
pango_glyph_string_free(glyphs);
#endif
} while (!bad_glyph && pango_layout_iter_next_run(run_iter));
pango_layout_iter_free(run_iter);