From: Rashad Tatum <tatum.rashad@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Rashad Tatum <tatum.rashad@gmail.com>
Subject: [FFmpeg-devel] [PATCH] libavformat/rtsp: Change ff_sdp_parse and sdp_parse_line to handle memory alloc errors
Date: Sat, 1 Mar 2025 16:00:42 -0500
Message-ID: <20250301210042.2002528-1-tatum.rashad@gmail.com> (raw)
for RTSPStream and RTSPSource
---
libavformat/rtsp.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 25a7602832..c5c47801cc 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -423,7 +423,7 @@ static void parse_fmtp(AVFormatContext *s, RTSPState *rt,
}
}
-static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
+static int sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
int letter, const char *buf)
{
RTSPState *rt = s->priv_data;
@@ -504,7 +504,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
}
rtsp_st = av_mallocz(sizeof(RTSPStream));
if (!rtsp_st)
- return;
+ return AVERROR(ENOMEM);
rtsp_st->stream_index = -1;
dynarray_add(&rt->rtsp_streams, &rt->nb_rtsp_streams, rtsp_st);
@@ -677,7 +677,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
rtsp_src = av_mallocz(sizeof(*rtsp_src));
if (!rtsp_src) {
av_freep(&dest_addr);
- return;
+ return AVERROR(ENOMEM);
}
av_strlcpy(rtsp_src->dest_addr, dest_addr, sizeof(rtsp_src->dest_addr));
get_word(rtsp_src->src_addr, sizeof(rtsp_src->src_addr), &p);
@@ -721,7 +721,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
int ff_sdp_parse(AVFormatContext *s, const char *content)
{
const char *p;
- int letter, i;
+ int letter, i, err;
char buf[SDP_MAX_SIZE], sdp_ip_str[50], *q;
bool parsed_first_media_desc = false;
SDPParseState sdp_parse_state = { { 0 } }, *s1 = &sdp_parse_state;
@@ -762,7 +762,10 @@ int ff_sdp_parse(AVFormatContext *s, const char *content)
}
*q = '\0';
- sdp_parse_line(s, s1, letter, buf);
+ err = sdp_parse_line(s, s1, letter, buf);
+ if (err < 0 )
+ return err;
+
if(letter == 'm')
parsed_first_media_desc = true;
--
2.48.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
reply other threads:[~2025-03-01 21:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250301210042.2002528-1-tatum.rashad@gmail.com \
--to=tatum.rashad@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git