From bf4bd8ef04539fd7064e10886cce4f6895ea529c Mon Sep 17 00:00:00 2001 From: Angus71 Date: Sun, 25 Aug 2019 09:50:40 +0200 Subject: [PATCH] Clean up --- rtsp.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/rtsp.c b/rtsp.c index c830bb25..1b198c69 100644 --- a/rtsp.c +++ b/rtsp.c @@ -1867,7 +1867,7 @@ static void handle_announce(rtsp_conn_info *conn, rtsp_message *req, rtsp_messag conn->stream.type = ast_apple_lossless; debug(3, "An ALAC stream has been detected."); - // Set connection defaults + // Set reasonable connection defaults conn->stream.fmtp[0] = 96; conn->stream.fmtp[1] = 352; conn->stream.fmtp[2] = 0; @@ -1881,15 +1881,11 @@ static void handle_announce(rtsp_conn_info *conn, rtsp_message *req, rtsp_messag conn->stream.fmtp[10] = 0; conn->stream.fmtp[11] = 44100; - unsigned int i; + unsigned int i = 0; + unsigned int max_param = sizeof(conn->stream.fmtp) / sizeof(conn->stream.fmtp[0]); char* found; - for (i = 0; i < sizeof(conn->stream.fmtp) / sizeof(conn->stream.fmtp[0]); i++) { - found = strsep(&pfmtp, " \t"); - if (found != NULL) { - conn->stream.fmtp[i] = atoi(found); - } else { - break; - } + while ((found = strsep(&pfmtp, " \t")) != NULL && i < max_param) { + conn->stream.fmtp[i++] = atoi(found); } // here we should check the sanity of the fmtp values // for (i = 0; i < sizeof(conn->stream.fmtp) / sizeof(conn->stream.fmtp[0]); i++) -- 2.47.2