aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-07-02 03:06:27 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2016-08-01 17:29:14 +0200
commite4eab67a0aed7c8962f7be2f482399048062e8a4 (patch)
tree0ba8b13623b5c7c34bc373e7a3032540e4b574a0
parent86f92287404286d01e6d9e65e63242637f1850d0 (diff)
downloadffmpeg-e4eab67a0aed7c8962f7be2f482399048062e8a4.tar.gz
avcodec/h264_parser: Set sps/pps_ref
Fixes use of freed memory Should fix valgrind failures of fate-h264-skip-nointra Found-by: logan Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit febc862b53c090e530b943ebd873747addf5f913) Conflicts: libavcodec/h264_parser.c
-rw-r--r--libavcodec/h264_parser.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index ce4bab225e..52c1d41784 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -367,13 +367,26 @@ static inline int parse_nal_units(AVCodecParserContext *s,
"non-existing PPS %u referenced\n", pps_id);
goto fail;
}
- p->ps.pps = (const PPS*)p->ps.pps_list[pps_id]->data;
+
+ av_buffer_unref(&p->ps.pps_ref);
+ av_buffer_unref(&p->ps.sps_ref);
+ p->ps.pps = NULL;
+ p->ps.sps = NULL;
+ p->ps.pps_ref = av_buffer_ref(p->ps.pps_list[pps_id]);
+ if (!p->ps.pps_ref)
+ goto fail;
+ p->ps.pps = (const PPS*)p->ps.pps_ref->data;
+
if (!p->ps.sps_list[p->ps.pps->sps_id]) {
av_log(avctx, AV_LOG_ERROR,
"non-existing SPS %u referenced\n", p->ps.pps->sps_id);
goto fail;
}
- p->ps.sps = (SPS*)p->ps.sps_list[p->ps.pps->sps_id]->data;
+
+ p->ps.sps_ref = av_buffer_ref(p->ps.sps_list[p->ps.pps->sps_id]);
+ if (!p->ps.sps_ref)
+ goto fail;
+ p->ps.sps = (SPS*)p->ps.sps_ref->data;
sps = p->ps.sps;