Message ID | GV1P250MB07376CB29C883B97C93CDC4E8F479@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM |
---|---|
State | Accepted |
Headers | show |
Series | [FFmpeg-devel,1/3] avutil/dict: Fix memleak when using AV_DICT_APPEND | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
On 9/13/22, Andreas Rheinhardt <andreas.rheinhardt@outlook.com> wrote: > We know that an AVDictionary is not empty if we have just added > an entry to it, so only check for it being empty on the branch > that does not do so. > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> > --- > libavutil/dict.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > LGTM > diff --git a/libavutil/dict.c b/libavutil/dict.c > index 1968063b0b..4bba041d0a 100644 > --- a/libavutil/dict.c > +++ b/libavutil/dict.c > @@ -123,12 +123,12 @@ int av_dict_set(AVDictionary **pm, const char *key, > const char *value, > m->elems[m->count].value = copy_value; > m->count++; > } else { > + if (!m->count) { > + av_freep(&m->elems); > + av_freep(pm); > + } > av_freep(©_key); > } > - if (!m->count) { > - av_freep(&m->elems); > - av_freep(pm); > - } > > return 0; > > -- > 2.34.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". >
diff --git a/libavutil/dict.c b/libavutil/dict.c index 1968063b0b..4bba041d0a 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -123,12 +123,12 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, m->elems[m->count].value = copy_value; m->count++; } else { + if (!m->count) { + av_freep(&m->elems); + av_freep(pm); + } av_freep(©_key); } - if (!m->count) { - av_freep(&m->elems); - av_freep(pm); - } return 0;
We know that an AVDictionary is not empty if we have just added an entry to it, so only check for it being empty on the branch that does not do so. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavutil/dict.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)