From 5319d4d979485e5508f545fe68dd54e40a2be7d0 Mon Sep 17 00:00:00 2001 From: Keith Date: Fri, 9 Aug 2019 01:14:43 +0200 Subject: [PATCH] coverity: Address issue found by coverity Add NULL checks on the return value of call_leg_other() in update_rtp() If the remote side has requested media change and we cannot find the other leg, then release call. This should not happen. Also, Add an assert to show that we cannot be here without call type of SIP or MNCC (not related to coverity) Fixes: CID#202863 Change-Id: I6f1f26533a25c93f243090bc02f1bc83b9108d42 --- src/mncc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mncc.c b/src/mncc.c index f5a44d5..e23bd6f 100644 --- a/src/mncc.c +++ b/src/mncc.c @@ -211,11 +211,21 @@ static void update_rtp(struct call_leg *_leg) { if (_leg->type == CALL_TYPE_MNCC) { leg = (struct mncc_call_leg *) _leg; struct call_leg *other = call_leg_other(&leg->base); + if (!other) + goto ret_release; send_rtp_connect(leg, other); - } else { + } else if (_leg->type == CALL_TYPE_SIP) { leg = (struct mncc_call_leg *) call_leg_other(_leg); + if (!leg) + goto ret_release; send_rtp_connect(leg, _leg); + } else { + OSMO_ASSERT(false); } + return; +ret_release: + LOGP(DMNCC, LOGL_ERROR, "Failed to find other leg.\n"); + _leg->release_call(_leg); }