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

Lukasz Marek lukasz.m.luki2 at gmail.com
Thu Apr 2 00:37:34 CEST 2015


On 01.04.2015 04:33, Michael Niedermayer wrote:
> 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 ?


something like attached?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavu-dict-fix-set-function-when-reuse-existing-key-p.patch
Type: text/x-patch
Size: 3474 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150402/b7d93198/attachment.bin>


More information about the ffmpeg-devel mailing list