summaryrefslogtreecommitdiff
path: root/res/res_srtp.c
diff options
context:
space:
mode:
Diffstat (limited to 'res/res_srtp.c')
-rw-r--r--res/res_srtp.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/res/res_srtp.c b/res/res_srtp.c
index b9499f8f1..549a1eaeb 100644
--- a/res/res_srtp.c
+++ b/res/res_srtp.c
@@ -366,7 +366,8 @@ tryagain:
ast_debug(5, "SRTP try to re-create\n");
if (policy) {
- if (srtp_create(&srtp->session, &policy->sp) == err_status_ok) {
+ int res_srtp_create = srtp_create(&srtp->session, &policy->sp);
+ if (res_srtp_create == err_status_ok) {
ast_debug(5, "SRTP re-created with first policy\n");
ao2_t_ref(policy, -1, "Unreffing first policy for re-creating srtp session");
@@ -383,15 +384,23 @@ tryagain:
retry++;
ao2_iterator_destroy(&it);
goto tryagain;
- } else {
- srtp->session = NULL;
}
+ ast_log(LOG_ERROR, "SRTP session could not be re-created after unprotect failure: %s\n", srtp_errstr(res_srtp_create));
+
+ /* If srtp_create() fails with a previously alloced session, it will have been dealloced before returning. */
+ srtp->session = NULL;
+
ao2_t_ref(policy, -1, "Unreffing first policy after srtp_create failed");
}
ao2_iterator_destroy(&it);
}
}
+ if (!srtp->session) {
+ errno = EINVAL;
+ return -1;
+ }
+
if (res != err_status_ok && res != err_status_replay_fail ) {
if ((srtp->warned >= 10) && !((srtp->warned - 10) % 100)) {
ast_log(AST_LOG_WARNING, "SRTP unprotect failed with: %s %d\n", srtp_errstr(res), srtp->warned);