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,19 +1754,25 @@ FLAC__bool do_shorthand_operation__vorbis_comment(const char *filename, FLAC__Me ...@@ -1754,19 +1754,25 @@ FLAC__bool do_shorthand_operation__vorbis_comment(const char *filename, FLAC__Me
found_vc_block = true; found_vc_block = true;
} while(!found_vc_block && FLAC__metadata_iterator_next(iterator)); } while(!found_vc_block && FLAC__metadata_iterator_next(iterator));
/* create a new block if necessary */ if(!found_vc_block) {
if(!found_vc_block && operation->type == OP__SET_VC_FIELD) { /* create a new block if necessary */
block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT); if(operation->type == OP__SET_VC_FIELD || operation->type == OP__IMPORT_VC_FROM) {
if(0 == block) block = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
die("out of memory allocating VORBIS_COMMENT block"); if(0 == block)
while(FLAC__metadata_iterator_next(iterator)) die("out of memory allocating VORBIS_COMMENT block");
; while(FLAC__metadata_iterator_next(iterator))
if(!FLAC__metadata_iterator_insert_block_after(iterator, block)) { ;
fprintf(stderr, "%s: ERROR: adding new VORBIS_COMMENT block to metadata, status =\"%s\"\n", filename, FLAC__Metadata_ChainStatusString[FLAC__metadata_chain_status(chain)]); if(!FLAC__metadata_iterator_insert_block_after(iterator, block)) {
return false; fprintf(stderr, "%s: ERROR: adding new VORBIS_COMMENT block to metadata, status =\"%s\"\n", filename, FLAC__Metadata_ChainStatusString[FLAC__metadata_chain_status(chain)]);
return false;
}
/* iterator is left pointing to new block */
FLAC__ASSERT(FLAC__metadata_iterator_get_block(iterator) == block);
}
else {
FLAC__metadata_iterator_delete(iterator);
return ok;
} }
/* iterator is left pointing to new block */
FLAC__ASSERT(FLAC__metadata_iterator_get_block(iterator) == block);
} }
FLAC__ASSERT(0 != block); FLAC__ASSERT(0 != block);
......
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