Fixes leaving a pointer to unreferenced memory Fixes Ticket 3115 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>tags/n2.3
| @@ -2966,6 +2966,8 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx) | |||||
| for (i = 0; i < FF_ARRAY_ELEMS(s->pps_list); i++) | for (i = 0; i < FF_ARRAY_ELEMS(s->pps_list); i++) | ||||
| av_buffer_unref(&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.entry_point_offset); | ||||
| av_freep(&s->sh.offset); | av_freep(&s->sh.offset); | ||||
| av_freep(&s->sh.size); | av_freep(&s->sh.size); | ||||
| @@ -3088,6 +3090,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); | |||||
| if (s->sps != s0->sps) | if (s->sps != s0->sps) | ||||
| ret = set_sps(s, s0->sps); | ret = set_sps(s, s0->sps); | ||||
| @@ -788,6 +788,8 @@ typedef struct HEVCContext { | |||||
| AVBufferRef *sps_list[MAX_SPS_COUNT]; | AVBufferRef *sps_list[MAX_SPS_COUNT]; | ||||
| AVBufferRef *pps_list[MAX_PPS_COUNT]; | AVBufferRef *pps_list[MAX_PPS_COUNT]; | ||||
| AVBufferRef *current_sps; | |||||
| AVBufferPool *tab_mvf_pool; | AVBufferPool *tab_mvf_pool; | ||||
| AVBufferPool *rpl_tab_pool; | AVBufferPool *rpl_tab_pool; | ||||
| @@ -331,6 +331,9 @@ static void hevc_close(AVCodecParserContext *s) | |||||
| for (i = 0; i < FF_ARRAY_ELEMS(h->pps_list); i++) | for (i = 0; i < FF_ARRAY_ELEMS(h->pps_list); i++) | ||||
| av_buffer_unref(&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++) | for (i = 0; i < h->nals_allocated; i++) | ||||
| av_freep(&h->nals[i].rbsp_buffer); | av_freep(&h->nals[i].rbsp_buffer); | ||||
| av_freep(&h->nals); | av_freep(&h->nals); | ||||
| @@ -964,6 +964,10 @@ int ff_hevc_decode_nal_sps(HEVCContext *s) | |||||
| if (s->pps_list[i] && ((HEVCPPS*)s->pps_list[i]->data)->sps_id == sps_id) | if (s->pps_list[i] && ((HEVCPPS*)s->pps_list[i]->data)->sps_id == sps_id) | ||||
| av_buffer_unref(&s->pps_list[i]); | 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]); | av_buffer_unref(&s->sps_list[sps_id]); | ||||
| s->sps_list[sps_id] = sps_buf; | s->sps_list[sps_id] = sps_buf; | ||||
| } | } | ||||