[FFmpeg-cvslog] rtsp: Do not assume getnameinfo cannot fail

Luca Barbato git at videolan.org
Sun Nov 29 16:10:19 CET 2015


ffmpeg | branch: master | Luca Barbato <lu_zero at gentoo.org> | Mon Nov 23 23:57:47 2015 +0100| [98063bcf15eb1e9bf9c8758c83c88d51cbb7ace7] | committer: Luca Barbato

rtsp: Do not assume getnameinfo cannot fail

And properly report the error when it happens.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=98063bcf15eb1e9bf9c8758c83c88d51cbb7ace7
---

 libavformat/rtsp.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index f62e370..8a94baf 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -2264,8 +2264,14 @@ static int sdp_read_header(AVFormatContext *s)
         if (!(rt->rtsp_flags & RTSP_FLAG_CUSTOM_IO)) {
             AVDictionary *opts = map_to_opts(rt);
 
-            getnameinfo((struct sockaddr*) &rtsp_st->sdp_ip, sizeof(rtsp_st->sdp_ip),
-                        namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
+            err = getnameinfo((struct sockaddr*) &rtsp_st->sdp_ip,
+                              sizeof(rtsp_st->sdp_ip),
+                              namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
+            if (err) {
+                av_log(s, AV_LOG_ERROR, "getnameinfo: %s\n", gai_strerror(err));
+                err = AVERROR(EIO);
+                goto fail;
+            }
             ff_url_join(url, sizeof(url), "rtp", NULL,
                         namebuf, rtsp_st->sdp_port,
                         "?localport=%d&ttl=%d&connect=%d&write_to_source=%d",



More information about the ffmpeg-cvslog mailing list