aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/tests
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2024-05-20 21:55:44 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2024-05-28 03:48:05 +0200
commite8a1e1899d9ededd78f8ec4722fe80c345bbf8f7 (patch)
tree30ce51953843e0dcd5d391daf2835dc0ab4c3143 /libavutil/tests
parent87846f64b5705f2759c157b80073fc841ecc0876 (diff)
downloadffmpeg-e8a1e1899d9ededd78f8ec4722fe80c345bbf8f7.tar.gz
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@niedermayer.cc>
Diffstat (limited to 'libavutil/tests')
-rw-r--r--libavutil/tests/dict.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libavutil/tests/dict.c b/libavutil/tests/dict.c
index e45bc220cb..21368203ce 100644
--- a/libavutil/tests/dict.c
+++ b/libavutil/tests/dict.c
@@ -150,12 +150,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);