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
This commit is contained in:
sesse 2010-03-17 23:42:11 +00:00
parent c7dbfb6467
commit 67b20ea611
1 changed files with 3 additions and 8 deletions

View File

@ -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_lock(&memmut);
if (last_alloc)
{
pthread_mutex_init(&memmut, NULL);
pthread_mutex_lock(&memmut);
}
else
{
pthread_mutex_lock(&memmut);
last_alloc->next = header; /* set next */
}