diff options
author | Jakub Adam <jakub.adam@ktknet.cz> | 2018-07-19 18:35:40 +0200 |
---|---|---|
committer | Jakub Adam <jakub.adam@ktknet.cz> | 2018-07-19 18:35:40 +0200 |
commit | d418291acec22ed6ea9b44c8b269e5c510cabb65 (patch) | |
tree | 08e7b91d864a0a470411fc805fd525ffdc6821dc | |
parent | 46d5fe343f91883d6b3a8d446f780107c5c3a4fa (diff) | |
download | pidgin-d418291acec22ed6ea9b44c8b269e5c510cabb65.tar.gz |
mediamanager: prevent r/w timers double free
Check we have nonzero readable_cb_token or writable_cb_token in
PurpleMediaAppDataInfo before removing the respective timeout. Zero
token means the timeout has been already cancelled by returning FALSE
from the timeout's GSourceFunc and we shouldn't remove it again.
In the best case, this change avoids 'Source ID xxx was not found when
attempting to remove it' warnings from GLib. In the worst case it avoids
accidental removal of an unrelated GSource if the source ID has been
meanwhile reused.
-rw-r--r-- | libpurple/mediamanager.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/libpurple/mediamanager.c b/libpurple/mediamanager.c index 7df23b8821..e6e8975ea4 100644 --- a/libpurple/mediamanager.c +++ b/libpurple/mediamanager.c @@ -629,19 +629,17 @@ free_appdata_info_locked (PurpleMediaAppDataInfo *info) g_free (info->session_id); g_free (info->participant); - /* This lets the potential read or write callbacks waiting for appdata_mutex - * know the info structure has been destroyed. */ - info->readable_cb_token = 0; - info->writable_cb_token = 0; + /* Zeroing out *_cb_token lets the read or write callbacks waiting for + * appdata_mutex know the info structure has been destroyed. */ - if (info->readable_timer_id) { + if (info->readable_cb_token) { purple_timeout_remove (info->readable_timer_id); - info->readable_timer_id = 0; + info->readable_cb_token = 0; } - if (info->writable_timer_id) { + if (info->writable_cb_token) { purple_timeout_remove (info->writable_timer_id); - info->writable_timer_id = 0; + info->writable_cb_token = 0; } if (info->current_sample) |