Skip to content

Commit

Permalink
TDNS: Fix a use-after-free-race-with-threads
Browse files Browse the repository at this point in the history
Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information
psychon committed Jan 19, 2012
1 parent 6a2b5a2 commit beacc01
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ void* CSockManager::TDNSThread(void* argument) {
sleep(5); // wait 5 seconds before next try
}

pthread_mutex_lock(a->mutex);
pthread_mutex_t* mutex = a->mutex;
pthread_mutex_lock(mutex);
int wrote = 0;
int need = sizeof(TDNSArg*);
char* x = (char*)&a;
Expand All @@ -89,7 +90,7 @@ void* CSockManager::TDNSThread(void* argument) {
wrote += w;
x += w;
}
pthread_mutex_unlock(a->mutex);
pthread_mutex_unlock(mutex);
return NULL;
}

Expand Down

0 comments on commit beacc01

Please sign in to comment.