From c50024fa3080b8b6f3be06ee6a31a66377ee6e28 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Fri, 1 Mar 2019 23:43:02 +0100 Subject: [PATCH] Revert "Revert "workaround for double malloc if container_ffmpeg_stop is not called after file play to end"" This reverts commit 83d9b453fcfcb1907a633c112b54a4dbc325fe14. Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/8b8b6b74b9168ce57126fb0e07da470d9aff8f7d Author: vanhofen Date: 2019-03-01 (Fri, 01 Mar 2019) ------------------ This commit was generated by Migit --- libeplayer3-arm/container/container_ffmpeg.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libeplayer3-arm/container/container_ffmpeg.c b/libeplayer3-arm/container/container_ffmpeg.c index ea9fb36..074155c 100644 --- a/libeplayer3-arm/container/container_ffmpeg.c +++ b/libeplayer3-arm/container/container_ffmpeg.c @@ -1533,7 +1533,9 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, uin 0 == strncmp(filename, "file://", 7)) { AVIOContext *avio_ctx = NULL; - custom_io_tab[AVIdx] = malloc(sizeof(CustomIOCtx_t)); + if(custom_io_tab[AVIdx] == NULL)//workaround for double malloc if container_ffmpeg_stop is not called after file play to end + custom_io_tab[AVIdx] = malloc(sizeof(CustomIOCtx_t)); + memset(custom_io_tab[AVIdx], 0x00, sizeof(CustomIOCtx_t)); custom_io_tab[AVIdx]->szFile = filename; @@ -2731,7 +2733,11 @@ static int32_t container_ffmpeg_stop(Context_t *context) fclose(io->pFile); if (io->pMoovFile) fclose(io->pMoovFile); - free(custom_io_tab[i]); + if(custom_io_tab[i] != NULL) + { + free(custom_io_tab[i]); + custom_io_tab[i] = NULL; + } av_freep(&(avContextTab[i]->pb->buffer)); av_freep(&(avContextTab[i]->pb)); use_custom_io[i] = 0;