[vlc-devel] [PATCH 2/3] avcodec: copy the key/values as they will be freed during av_dict_free()

Steve Lhomme robux4 at videolabs.io
Fri Aug 5 09:20:04 CEST 2016


av_free() assumes the memory was allocated with av_alloc(). It will assert
if CONFIG_MEMALIGN_HACK is enabled.
---
 modules/codec/avcodec/avcommon.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/modules/codec/avcodec/avcommon.h b/modules/codec/avcodec/avcommon.h
index 1373487..f612a36 100644
--- a/modules/codec/avcodec/avcommon.h
+++ b/modules/codec/avcodec/avcommon.h
@@ -52,8 +52,9 @@ static inline AVDictionary *vlc_av_get_options(const char *psz_opts)
     config_ChainParseOptions(&cfg, psz_opts);
     while (cfg) {
         config_chain_t *next = cfg->p_next;
-        av_dict_set(&options, cfg->psz_name, cfg->psz_value,
-            AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
+        av_dict_set(&options, cfg->psz_name, cfg->psz_value, 0);
+        free(cfg->psz_name);
+        free(cfg->psz_value);
         free(cfg);
         cfg = next;
     }
-- 
2.8.2



More information about the vlc-devel mailing list