aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-07-12 06:36:25 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-07-15 22:16:07 +0200
commit5302fa522bcf0da381fcc671ec0c22c7fbcdd73a (patch)
treea80e6868a5c851bd05a26d7c1094ecf66811a6c5
parent27375c25d9c810b45501f5fd5425f637d17da0bf (diff)
downloadffmpeg-5302fa522bcf0da381fcc671ec0c22c7fbcdd73a.tar.gz
avcodec/hevc_ps: do not loose all reference to pointers still in use
Fixes leaving a pointer to unreferenced memory Fixes Ticket 3115 Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit ccd6911c189d2f974dcc4095c963dfad14d703d2) Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit ec0ec65ee46d1367938dc46036fe61ad0384cbd5) Conflicts: libavcodec/hevc.c
-rw-r--r--libavcodec/hevc.c6
-rw-r--r--libavcodec/hevc.h2
-rw-r--r--libavcodec/hevc_parser.c3
-rw-r--r--libavcodec/hevc_ps.c4
4 files changed, 15 insertions, 0 deletions
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index ff42d6e5d3..e0f35286e9 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -2700,6 +2700,8 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
for (i = 0; i < FF_ARRAY_ELEMS(s->pps_list); i++)
av_buffer_unref(&s->pps_list[i]);
+ av_buffer_unref(&s->current_sps);
+
av_freep(&s->sh.entry_point_offset);
av_freep(&s->sh.offset);
av_freep(&s->sh.size);
@@ -2813,6 +2815,10 @@ static int hevc_update_thread_context(AVCodecContext *dst,
}
}
+ if (s->current_sps && s->sps == (HEVCSPS*)s->current_sps->data)
+ s->sps = NULL;
+ av_buffer_unref(&s->current_sps);
+
s->seq_decode = s0->seq_decode;
s->seq_output = s0->seq_output;
s->pocTid0 = s0->pocTid0;
diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index 1a115cf40e..ac539a2a98 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc.h
@@ -786,6 +786,8 @@ typedef struct HEVCContext {
AVBufferRef *sps_list[MAX_SPS_COUNT];
AVBufferRef *pps_list[MAX_PPS_COUNT];
+ AVBufferRef *current_sps;
+
AVBufferPool *tab_mvf_pool;
AVBufferPool *rpl_tab_pool;
diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 642f9752a4..0a75f20d19 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -329,6 +329,9 @@ static void hevc_close(AVCodecParserContext *s)
for (i = 0; i < FF_ARRAY_ELEMS(h->pps_list); i++)
av_buffer_unref(&h->pps_list[i]);
+ av_buffer_unref(&h->current_sps);
+ h->sps = NULL;
+
for (i = 0; i < h->nals_allocated; i++)
av_freep(&h->nals[i].rbsp_buffer);
av_freep(&h->nals);
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index a382172ad3..99ac8efa0d 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -934,6 +934,10 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
if (s->pps_list[i] && ((HEVCPPS*)s->pps_list[i]->data)->sps_id == sps_id)
av_buffer_unref(&s->pps_list[i]);
}
+ if (s->sps_list[sps_id] && s->sps == (HEVCSPS*)s->sps_list[sps_id]->data) {
+ av_buffer_unref(&s->current_sps);
+ s->current_sps = av_buffer_ref(s->sps_list[sps_id]);
+ }
av_buffer_unref(&s->sps_list[sps_id]);
s->sps_list[sps_id] = sps_buf;
}