gkimmulticontext: Fix crash due to leaked signal handler

The problem is caused by gtk_im_multicontext_set_slave(), which forgets
to disconnect these signal handlers:
* gtk_im_multicontext_retrieve_surrounding_cb
* gtk_im_multicontext_delete_surrounding_cb

If slave GtkImContext emits signal after GtkIMMulticontext context is
destroyed, this leads to reading freed memory, sometimes causing a crash.

Fixes: #2365
This commit is contained in:
Alexandr Miloslavskiy 2019-12-17 12:44:33 +01:00
parent cb81e3ee47
commit 32f088e335

View File

@ -189,6 +189,12 @@ gtk_im_multicontext_set_slave (GtkIMMulticontext *multicontext,
g_signal_handlers_disconnect_by_func (priv->slave,
gtk_im_multicontext_commit_cb,
multicontext);
g_signal_handlers_disconnect_by_func (priv->slave,
gtk_im_multicontext_retrieve_surrounding_cb,
multicontext);
g_signal_handlers_disconnect_by_func (priv->slave,
gtk_im_multicontext_delete_surrounding_cb,
multicontext);
g_object_unref (priv->slave);
priv->slave = NULL;