GNOME Bugzilla – Bug 658561
Double free after calling Pango.Context.get_font_description() from python
Last modified: 2011-09-08 23:53:13 UTC
If I call Pango.Context.get_font_description() from python, using gi, I get a crash on exit from the function which called that. There's a sort of backtrace which says it's caused by a double free or corruption in pango_font_description_free. I guess the problem is that python thinks it "owns" the PangoFontDescription object, but the description of pango_context_get_font_description (C version) says it returns "a pointer to the context's default font description. This value must not be modified or freed." However, the result is not const, which might have led to an oversight in gir that this object needs special treatment eg pango_font_description_copy_static().
I committed this patch. Can you test? diff --git a/pango/pango-context.c b/pango/pango-context.c index 110a6f3..6c1508b 100644 --- a/pango/pango-context.c +++ b/pango/pango-context.c @@ -339,8 +339,8 @@ pango_context_set_font_description (PangoContext *context, * * Retrieve the default font description for the context. * - * Return value: a pointer to the context's default font description. - * This value must not be modified or freed. + * Return value: (transfer none) a pointer to the context's default font + * description. This value must not be modified or freed. **/ PangoFontDescription * pango_context_get_font_description (PangoContext *context)
Unfortunately the gir parser doesn't seem to recognise that: <method name="get_font_description" c:identifier="pango_context_get_font_description"> <doc xml:whitespace="preserve">Retrieve the default font description for the context. description. This value must not be modified or freed.</doc> <return-value transfer-ownership="full"> <doc xml:whitespace="preserve">(transfer none) a pointer to the context's default font</doc> <type name="FontDescription" c:type="PangoFontDescription*"/> </return-value> </method> I noticed the similar pango_layout_get_font_description has transfer-ownership="none" and that has the G_CONST_RETURN attribute. Can that be added here without breaking other things? Or do I need a newer gir scanner?
My bad. Need a colon after "(transfer none)". Pushed fix.
That seems to fix it for me, thanks.