[FFmpeg-cvslog] avutil/tests/dict: Check av_dict_set() before get for failure
Michael Niedermayer
git at videolan.org
Thu Jun 13 23:41:21 EEST 2024
ffmpeg | branch: release/5.1 | Michael Niedermayer <michael at niedermayer.cc> | Mon May 20 21:55:44 2024 +0200| [3ab1855847eca3991d425e20235a4616cd943ab6] | committer: Michael Niedermayer
avutil/tests/dict: Check av_dict_set() before get for failure
Failure is possible due to strdup()
Fixes: CID1516764 Dereference null return value
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit e8a1e1899d9ededd78f8ec4722fe80c345bbf8f7)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3ab1855847eca3991d425e20235a4616cd943ab6
---
libavutil/tests/dict.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/libavutil/tests/dict.c b/libavutil/tests/dict.c
index 56e98557a7..4c526f72f4 100644
--- a/libavutil/tests/dict.c
+++ b/libavutil/tests/dict.c
@@ -122,12 +122,15 @@ int main(void)
//valgrind sensible test
printf("\nTesting av_dict_set() with existing AVDictionaryEntry.key as key\n");
- av_dict_set(&dict, "key", "old", 0);
+ if (av_dict_set(&dict, "key", "old", 0) < 0)
+ return 1;
e = av_dict_get(dict, "key", NULL, 0);
- av_dict_set(&dict, e->key, "new val OK", 0);
+ if (av_dict_set(&dict, e->key, "new val OK", 0) < 0)
+ return 1;
e = av_dict_get(dict, "key", NULL, 0);
printf("%s\n", e->value);
- av_dict_set(&dict, e->key, e->value, 0);
+ if (av_dict_set(&dict, e->key, e->value, 0) < 0)
+ return 1;
e = av_dict_get(dict, "key", NULL, 0);
printf("%s\n", e->value);
av_dict_free(&dict);
More information about the ffmpeg-cvslog
mailing list