[vlc-devel] commit: msg_Unsubscribe: race condition memory leak ( Rémi Denis-Courmont )
git version control
git at videolan.org
Wed Oct 15 18:11:45 CEST 2008
vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Wed Oct 15 19:11:22 2008 +0300| [3f6bd2669b0d9bc258a7a53183029991cec259aa] | committer: Rémi Denis-Courmont
msg_Unsubscribe: race condition memory leak
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3f6bd2669b0d9bc258a7a53183029991cec259aa
---
src/misc/messages.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/misc/messages.c b/src/misc/messages.c
index 087d9cd..29031f0 100644
--- a/src/misc/messages.c
+++ b/src/misc/messages.c
@@ -275,6 +275,15 @@ void msg_Unsubscribe (msg_subscription_t *sub)
vlc_mutex_unlock (&bank->lock);
vlc_join (sub->thread, NULL);
+
+ /* Free dangling (not flushed) messages. */
+ /* NOTE: no locking, only this thread can refer to the subscription now. */
+ while (sub->begin != sub->end)
+ {
+ msg_Release (sub->items[sub->begin]);
+ if (++sub->begin == VLC_MSG_QSIZE)
+ sub->begin = 0;
+ }
free (sub);
}
More information about the vlc-devel
mailing list