diff options
author | Mick Sayson <mick@sayson.com> | 2018-09-21 11:05:58 -0700 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-09-21 20:44:24 +0000 |
commit | dc0b2e79193ef303b1ae240e79996d4619138d31 (patch) | |
tree | da89e06cf2a623af06c77801602493ae59e380ac /toxav | |
parent | e43b2eadc003179c0f14e948ce6293bffde34188 (diff) |
Fix using uninitialized mutex on call end.
Diffstat (limited to 'toxav')
-rw-r--r-- | toxav/toxav.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/toxav/toxav.c b/toxav/toxav.c index c8d8a274..4cdd7d84 100644 --- a/toxav/toxav.c +++ b/toxav/toxav.c | |||
@@ -1180,10 +1180,18 @@ ToxAVCall *call_new(ToxAV *av, uint32_t friend_number, Toxav_Err_Call *error) | |||
1180 | call->av = av; | 1180 | call->av = av; |
1181 | call->friend_number = friend_number; | 1181 | call->friend_number = friend_number; |
1182 | 1182 | ||
1183 | if (create_recursive_mutex(call->mutex)) { | ||
1184 | free(call); | ||
1185 | call = nullptr; | ||
1186 | rc = TOXAV_ERR_CALL_MALLOC; | ||
1187 | goto RETURN; | ||
1188 | } | ||
1189 | |||
1183 | if (av->calls == nullptr) { /* Creating */ | 1190 | if (av->calls == nullptr) { /* Creating */ |
1184 | av->calls = (ToxAVCall **)calloc(sizeof(ToxAVCall *), friend_number + 1); | 1191 | av->calls = (ToxAVCall **)calloc(sizeof(ToxAVCall *), friend_number + 1); |
1185 | 1192 | ||
1186 | if (av->calls == nullptr) { | 1193 | if (av->calls == nullptr) { |
1194 | pthread_mutex_destroy(call->mutex); | ||
1187 | free(call); | 1195 | free(call); |
1188 | call = nullptr; | 1196 | call = nullptr; |
1189 | rc = TOXAV_ERR_CALL_MALLOC; | 1197 | rc = TOXAV_ERR_CALL_MALLOC; |
@@ -1196,6 +1204,7 @@ ToxAVCall *call_new(ToxAV *av, uint32_t friend_number, Toxav_Err_Call *error) | |||
1196 | ToxAVCall **tmp = (ToxAVCall **)realloc(av->calls, sizeof(ToxAVCall *) * (friend_number + 1)); | 1204 | ToxAVCall **tmp = (ToxAVCall **)realloc(av->calls, sizeof(ToxAVCall *) * (friend_number + 1)); |
1197 | 1205 | ||
1198 | if (tmp == nullptr) { | 1206 | if (tmp == nullptr) { |
1207 | pthread_mutex_destroy(call->mutex); | ||
1199 | free(call); | 1208 | free(call); |
1200 | call = nullptr; | 1209 | call = nullptr; |
1201 | rc = TOXAV_ERR_CALL_MALLOC; | 1210 | rc = TOXAV_ERR_CALL_MALLOC; |
@@ -1259,6 +1268,7 @@ ToxAVCall *call_remove(ToxAVCall *call) | |||
1259 | call->msi_call->av_call = nullptr; | 1268 | call->msi_call->av_call = nullptr; |
1260 | } | 1269 | } |
1261 | 1270 | ||
1271 | pthread_mutex_destroy(call->mutex); | ||
1262 | free(call); | 1272 | free(call); |
1263 | 1273 | ||
1264 | if (prev) { | 1274 | if (prev) { |
@@ -1314,10 +1324,6 @@ bool call_prepare_transmission(ToxAVCall *call) | |||
1314 | } | 1324 | } |
1315 | 1325 | ||
1316 | if (create_recursive_mutex(call->mutex_video) != 0) { | 1326 | if (create_recursive_mutex(call->mutex_video) != 0) { |
1317 | goto FAILURE_3; | ||
1318 | } | ||
1319 | |||
1320 | if (create_recursive_mutex(call->mutex) != 0) { | ||
1321 | goto FAILURE_2; | 1327 | goto FAILURE_2; |
1322 | } | 1328 | } |
1323 | 1329 | ||
@@ -1370,10 +1376,8 @@ FAILURE: | |||
1370 | vc_kill(call->video); | 1376 | vc_kill(call->video); |
1371 | call->video_rtp = nullptr; | 1377 | call->video_rtp = nullptr; |
1372 | call->video = nullptr; | 1378 | call->video = nullptr; |
1373 | pthread_mutex_destroy(call->mutex); | ||
1374 | FAILURE_2: | ||
1375 | pthread_mutex_destroy(call->mutex_video); | 1379 | pthread_mutex_destroy(call->mutex_video); |
1376 | FAILURE_3: | 1380 | FAILURE_2: |
1377 | pthread_mutex_destroy(call->mutex_audio); | 1381 | pthread_mutex_destroy(call->mutex_audio); |
1378 | return false; | 1382 | return false; |
1379 | } | 1383 | } |
@@ -1407,5 +1411,4 @@ void call_kill_transmission(ToxAVCall *call) | |||
1407 | 1411 | ||
1408 | pthread_mutex_destroy(call->mutex_audio); | 1412 | pthread_mutex_destroy(call->mutex_audio); |
1409 | pthread_mutex_destroy(call->mutex_video); | 1413 | pthread_mutex_destroy(call->mutex_video); |
1410 | pthread_mutex_destroy(call->mutex); | ||
1411 | } | 1414 | } |