From 67b20ea6112d99295134f2e1430e1ab9f8c88529 Mon Sep 17 00:00:00 2001 From: sesse Date: Wed, 17 Mar 2010 23:42:11 +0000 Subject: Fix thread safety issue in mreq_private: last_alloc was accessed from multiple threads without being under a mutex. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30928 b3059339-0415-0410-9bf9-f77b7e298cf2 --- loader/win32.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'loader') diff --git a/loader/win32.c b/loader/win32.c index b349ee91af..b687135049 100644 --- a/loader/win32.c +++ b/loader/win32.c @@ -146,7 +146,7 @@ static void longcount_stub(long long*); static unsigned int (*localcount)()=localcount_stub; static void (*longcount)(long long*)=longcount_stub; -static pthread_mutex_t memmut; +static pthread_mutex_t memmut = PTHREAD_MUTEX_INITIALIZER; static unsigned int localcount_stub(void) { @@ -366,14 +366,9 @@ void* mreq_private(int size, int to_zero, int type) if (to_zero) memset(header, 0, nsize); #ifdef GARBAGE - if (!last_alloc) - { - pthread_mutex_init(&memmut, NULL); - pthread_mutex_lock(&memmut); - } - else + pthread_mutex_lock(&memmut); + if (last_alloc) { - pthread_mutex_lock(&memmut); last_alloc->next = header; /* set next */ } -- cgit v1.2.3