]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/utils.c
avformat/mpc8: check avio_read() return in mpc8_parse_seektable()
[ffmpeg] / libavformat / utils.c
index 7f19abc5f17915662a9bc95a9a2172b30ee61e8f..40d886f58aa5734ed78c6690cbb815e9ac3abe4c 100644 (file)
@@ -2701,6 +2701,22 @@ int ff_alloc_extradata(AVCodecContext *avctx, int size)
     return ret;
 }
 
+int ff_get_extradata(AVCodecContext *avctx, AVIOContext *pb, int size)
+{
+    int ret = ff_alloc_extradata(avctx, size);
+    if (ret < 0)
+        return ret;
+    ret = avio_read(pb, avctx->extradata, size);
+    if (ret != size) {
+        av_freep(&avctx->extradata);
+        avctx->extradata_size = 0;
+        av_log(avctx, AV_LOG_ERROR, "Failed to read extradata of size %d\n", size);
+        return ret < 0 ? ret : AVERROR_INVALIDDATA;
+    }
+
+    return ret;
+}
+
 int ff_rfps_add_frame(AVFormatContext *ic, AVStream *st, int64_t ts)
 {
     int i, j;