@@ -875,20 +875,28 @@ const AVCodec *ff_find_decoder(AVFormatContext *s, const AVStream *st,
875
875
876
876
int ff_copy_whiteblacklists (AVFormatContext * dst , const AVFormatContext * src )
877
877
{
878
+ #define OFF (field ) offsetof(AVFormatContext, field)
879
+ static const unsigned offsets [] = {
880
+ OFF (codec_whitelist ), OFF (format_whitelist ),
881
+ OFF (protocol_whitelist ), OFF (protocol_blacklist ),
882
+ };
883
+ #undef OFF
878
884
av_assert0 (!dst -> codec_whitelist &&
879
885
!dst -> format_whitelist &&
880
886
!dst -> protocol_whitelist &&
881
887
!dst -> protocol_blacklist );
882
- dst -> codec_whitelist = av_strdup (src -> codec_whitelist );
883
- dst -> format_whitelist = av_strdup (src -> format_whitelist );
884
- dst -> protocol_whitelist = av_strdup (src -> protocol_whitelist );
885
- dst -> protocol_blacklist = av_strdup (src -> protocol_blacklist );
886
- if ( (src -> codec_whitelist && !dst -> codec_whitelist )
887
- || (src -> format_whitelist && !dst -> format_whitelist )
888
- || (src -> protocol_whitelist && !dst -> protocol_whitelist )
889
- || (src -> protocol_blacklist && !dst -> protocol_blacklist )) {
890
- av_log (dst , AV_LOG_ERROR , "Failed to duplicate black/whitelist\n" );
891
- return AVERROR (ENOMEM );
888
+ for (unsigned i = 0 ; i < FF_ARRAY_ELEMS (offsets ); i ++ ) {
889
+ const char * src_str = * (char * const * )((const char * )src + offsets [i ]);
890
+
891
+ if (src_str ) {
892
+ char * dst_str = av_strdup (src_str );
893
+ if (!dst_str ) {
894
+ av_log (dst , AV_LOG_ERROR , "Failed to duplicate black/whitelist\n" );
895
+ return AVERROR (ENOMEM );
896
+ }
897
+
898
+ * (char * * )((char * )dst + offsets [i ]) = dst_str ;
899
+ }
892
900
}
893
901
return 0 ;
894
902
}
0 commit comments