diff options
author | Richard Mudgett <rmudgett@digium.com> | 2015-07-29 17:00:05 -0500 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2015-07-30 17:11:58 -0500 |
commit | 33a465249b4688b83684e182c4bb26c6fcd7d2a3 (patch) | |
tree | dd72e95877da2d3811a0bd981429b8cb4a29aa5e /res/res_rtp_asterisk.c | |
parent | 5f925d48b7384b0aa8c779821fa44e9c4d52a923 (diff) |
res_rtp_asterisk.c: Fix off-nominal crash potential.
ASTERISK-25296
Reported by: Richard Mudgett
Change-Id: I08549fb7c3ab40a559f41a3940f3732a4059b55b
Diffstat (limited to 'res/res_rtp_asterisk.c')
-rw-r--r-- | res/res_rtp_asterisk.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c index 53e9b29c2..e5005b34f 100644 --- a/res/res_rtp_asterisk.c +++ b/res/res_rtp_asterisk.c @@ -4504,6 +4504,10 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc } payload = ast_rtp_codecs_get_payload(ast_rtp_instance_get_codecs(instance), payloadtype); + if (!payload) { + /* Unknown payload type. */ + return AST_LIST_FIRST(&frames) ? AST_LIST_FIRST(&frames) : &ast_null_frame; + } /* If the payload is not actually an Asterisk one but a special one pass it off to the respective handler */ if (!payload->asterisk_format) { @@ -4530,10 +4534,7 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc /* Even if no frame was returned by one of the above methods, * we may have a frame to return in our frame list */ - if (!AST_LIST_EMPTY(&frames)) { - return AST_LIST_FIRST(&frames); - } - return &ast_null_frame; + return AST_LIST_FIRST(&frames) ? AST_LIST_FIRST(&frames) : &ast_null_frame; } ao2_replace(rtp->lastrxformat, payload->format); |