瀏覽代碼

avformat/rtpdec_rfc4175: Only change PayloadContext on success

Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c03e49dd1d8ee2dd21c24002dfac95644c830498)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Michael Niedermayer 3 周之前
父節點
當前提交
d6e3e6f8fb
共有 1 個文件被更改,包括 14 次插入7 次删除
  1. 14 7
      libavformat/rtpdec_rfc4175.c

+ 14 - 7
libavformat/rtpdec_rfc4175.c

@@ -23,6 +23,7 @@
 
 #include "avio_internal.h"
 #include "rtpdec_formats.h"
+#include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/pixdesc.h"
@@ -172,33 +173,39 @@ static int rfc4175_parse_fmtp(AVFormatContext *s, AVStream *stream,
 }
 
 static int rfc4175_parse_sdp_line(AVFormatContext *s, int st_index,
-                                  PayloadContext *data, const char *line)
+                                  PayloadContext *data_arg, const char *line)
 {
     const char *p;
 
     if (st_index < 0)
         return 0;
 
+    av_assert0(!data_arg->sampling);
+
     if (av_strstart(line, "fmtp:", &p)) {
         AVStream *stream = s->streams[st_index];
+        PayloadContext data0 = *data_arg, *data = &data0;
         int ret = ff_parse_fmtp(s, stream, data, p, rfc4175_parse_fmtp);
 
+        if (!data->sampling || !data->depth || !data->width || !data->height)
+            ret =  AVERROR(EINVAL);
+
         if (ret < 0)
-            return ret;
+            goto fail;
 
         ret = av_image_check_size(data->width, data->height, 0, s);
         if (ret < 0)
-            return ret;
-
-        if (!data->sampling || !data->depth || !data->width || !data->height)
-            return AVERROR(EINVAL);
+            goto fail;
 
         stream->codecpar->width = data->width;
         stream->codecpar->height = data->height;
 
         ret = rfc4175_parse_format(stream, data);
         av_freep(&data->sampling);
-
+        if (ret >= 0)
+            *data_arg = *data;
+fail:
+        av_freep(&data->sampling);
         return ret;
     }