* [FFmpeg-devel] [PATCH] libavformat/rtsp: Change ff_sdp_parse and sdp_parse_line to handle memory alloc errors
@ 2025-03-01 21:00 Rashad Tatum
0 siblings, 0 replies; only message in thread
From: Rashad Tatum @ 2025-03-01 21:00 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Rashad Tatum
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".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-03-01 21:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-01 21:00 [FFmpeg-devel] [PATCH] libavformat/rtsp: Change ff_sdp_parse and sdp_parse_line to handle memory alloc errors Rashad Tatum
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