Possible memory corruption (use-after-free?) in Gtk.StyleContext.get_property
I am getting sporadic crashes in a Python program that is getting a style context from a GTK widget, extracting its font description and using it on a Pango layout: Pango crashes while accessing the font description.
I reduced the problem to this sample (Python 3):
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
ctx = Gtk.StyleContext()
desc = ctx.get_property('font', Gtk.StateFlags.NORMAL)
print(desc.to_string())
The to_string()
call usually raises a UnicodeDecodeError
, complaining about random bytes at random positions.
If it returns, print()
displays random garbage.
I suspect the font description is freed prematurely.
Interestingly, using the (deprecated) method Gtk.StyleContext.get_font
instead of get_property
seems to work without issues.
-
gi
version:3.34.0
-
gtk
version:3.24.13