Commit deb4132f authored by Josh Coalson's avatar Josh Coalson
Browse files

fix bug where importing vorbis comments to a flac file with no vorbis comment...

fix bug where importing vorbis comments to a flac file with no vorbis comment block corrupted the file
parent 057b5326
......@@ -1754,8 +1754,9 @@ FLAC__bool do_shorthand_operation__vorbis_comment(const char *filename, FLAC__Me
found_vc_block = true;
} while(!found_vc_block && FLAC__metadata_iterator_next(iterator));
if(!found_vc_block) {
/* create a new block if necessary */
if(!found_vc_block && operation->type == OP__SET_VC_FIELD) {
if(operation->type == OP__SET_VC_FIELD || operation->type == OP__IMPORT_VC_FROM) {
block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
if(0 == block)
die("out of memory allocating VORBIS_COMMENT block");
......@@ -1768,6 +1769,11 @@ FLAC__bool do_shorthand_operation__vorbis_comment(const char *filename, FLAC__Me
/* iterator is left pointing to new block */
FLAC__ASSERT(FLAC__metadata_iterator_get_block(iterator) == block);
}
else {
FLAC__metadata_iterator_delete(iterator);
return ok;
}
}
FLAC__ASSERT(0 != block);
FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment