File tree 3 files changed +18
-6
lines changed
3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -1025,11 +1025,6 @@ STATUS freeSampleConfiguration(PSampleConfiguration* ppSampleConfiguration)
1025
1025
MUTEX_LOCK (pSampleConfiguration -> sampleConfigurationObjLock );
1026
1026
locked = TRUE;
1027
1027
}
1028
- // Cancel the media thread
1029
- if (!(pSampleConfiguration -> mediaThreadStarted )) {
1030
- DLOGD ("Canceling media thread" );
1031
- THREAD_CANCEL (pSampleConfiguration -> mediaSenderTid );
1032
- }
1033
1028
1034
1029
for (i = 0 ; i < pSampleConfiguration -> streamingSessionCount ; ++ i ) {
1035
1030
retStatus = gatherIceServerStats (pSampleConfiguration -> sampleStreamingSessionList [i ]);
Original file line number Diff line number Diff line change @@ -122,6 +122,20 @@ INT32 main(INT32 argc, CHAR* argv[])
122
122
// Kick of the termination sequence
123
123
ATOMIC_STORE_BOOL (& pSampleConfiguration -> appTerminateFlag , TRUE);
124
124
125
+ if (IS_VALID_MUTEX_VALUE (pSampleConfiguration -> sampleConfigurationObjLock )) {
126
+ MUTEX_LOCK (pSampleConfiguration -> sampleConfigurationObjLock );
127
+ }
128
+
129
+ // Cancel the media thread
130
+ if (pSampleConfiguration -> mediaThreadStarted ) {
131
+ DLOGD ("Canceling media thread" );
132
+ THREAD_CANCEL (pSampleConfiguration -> mediaSenderTid );
133
+ }
134
+
135
+ if (IS_VALID_MUTEX_VALUE (pSampleConfiguration -> sampleConfigurationObjLock )) {
136
+ MUTEX_UNLOCK (pSampleConfiguration -> sampleConfigurationObjLock );
137
+ }
138
+
125
139
if (pSampleConfiguration -> mediaSenderTid != INVALID_TID_VALUE ) {
126
140
THREAD_JOIN (pSampleConfiguration -> mediaSenderTid , NULL );
127
141
}
Original file line number Diff line number Diff line change @@ -374,7 +374,10 @@ PVOID connectionListenerReceiveDataRoutine(PVOID arg)
374
374
375
375
CleanUp :
376
376
377
- if (pConnectionListener != NULL ) {
377
+ // The check for valid mutex is necessary because when we're in freeConnectionListener
378
+ // we may free the mutex in another thread so by the time we get here accessing the lock
379
+ // will result in accessing a resource after it has been freed
380
+ if (pConnectionListener != NULL && IS_VALID_MUTEX_VALUE (pConnectionListener -> lock )) {
378
381
// As TID is 64 bit we can't atomically update it and need to do it under the lock
379
382
MUTEX_LOCK (pConnectionListener -> lock );
380
383
pConnectionListener -> receiveDataRoutine = INVALID_TID_VALUE ;
You can’t perform that action at this time.
0 commit comments