1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-08 13:22:53 +02:00

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>
(cherry picked from commit e8a1e1899d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2024-05-20 21:55:44 +02:00
parent 6b0671a644
commit 8d969d2778
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64

View File

@ -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);