[FFmpeg-devel] [PATCH 1/2] lavu/dict: fix set function when reuse existing key pointer

Michael Niedermayer michaelni at gmx.at
Wed Apr 1 04:33:29 CEST 2015


On Wed, Apr 01, 2015 at 03:25:23AM +0200, Lukasz Marek wrote:
> Fixes following scenario:
> 
> av_dict_set(&d, "key", "old", 0);
> AVDictionaryEentry *e = av_dict_get(d, "key", NULL, 0);
> av_dict_set(&d, e->key, "new", 0);
> 
> Signed-off-by: Lukasz Marek <lukasz.m.luki2 at gmail.com>
> ---
>  libavutil/dict.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/libavutil/dict.c b/libavutil/dict.c
> index 0d54c79..3163894 100644
> --- a/libavutil/dict.c
> +++ b/libavutil/dict.c
> @@ -72,6 +72,7 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value,
>      AVDictionary *m = *pm;
>      AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
>      char *oldval = NULL;
> +    int the_same_key = 0;
>  

does it work to av_strdup() both key and value if they need to be
strduped but at the top of the function and simplify the rest
accordingly ?

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 3
"Rare item" - "Common item with rare defect or maybe just a lie"
"Professional" - "'Toy' made in china, not functional except as doorstop"
"Experts will know" - "The seller hopes you are not an expert"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150401/fab4eed6/attachment.asc>


More information about the ffmpeg-devel mailing list