[FLAC Decoder] Safety decoding for tag reader

Use tag string encoding guessing for tag decoding, just in case there
are invalid files with non-standard encoded strings inside the tags, or
if there are streams with such tags. We don't want any crashes.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
lastfm
Christopher Snowhill 2022-07-05 13:44:44 -07:00
parent d4b434a68f
commit 472272129b
1 changed files with 2 additions and 2 deletions

View File

@ -241,8 +241,8 @@ void MetadataCallback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMeta
char *_name; char *_name;
char *_value; char *_value;
if(FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair(vorbis_comment->comments[i], &_name, &_value)) { if(FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair(vorbis_comment->comments[i], &_name, &_value)) {
NSString *name = [NSString stringWithUTF8String:_name]; NSString *name = guess_encoding_of_string(_name);
NSString *value = [NSString stringWithUTF8String:_value]; NSString *value = guess_encoding_of_string(_value);
free(_name); free(_name);
free(_value); free(_value);
name = [name lowercaseString]; name = [name lowercaseString];