From: Josh Coalson Date: Mon, 15 Sep 2008 05:37:27 +0000 (+0000) Subject: fix bug in FLAC__metadata_object_vorbiscomment_replace_comment() X-Git-Tag: 1.3.0pre1~177 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e95399c19f04e6877949f3db7cef79ec846dba67;p=platform%2Fupstream%2Fflac.git fix bug in FLAC__metadata_object_vorbiscomment_replace_comment() --- diff --git a/src/libFLAC/metadata_object.c b/src/libFLAC/metadata_object.c index 7ebe319..4d68ac9 100644 --- a/src/libFLAC/metadata_object.c +++ b/src/libFLAC/metadata_object.c @@ -1265,16 +1265,21 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_replace_comment(FLAC__St field_name_length = eq-entry.entry; - if((i = vorbiscomment_find_entry_from_(object, 0, (const char *)entry.entry, field_name_length)) >= 0) { + i = vorbiscomment_find_entry_from_(object, 0, (const char *)entry.entry, field_name_length); + if(i >= 0) { unsigned index = (unsigned)i; if(!FLAC__metadata_object_vorbiscomment_set_comment(object, index, entry, copy)) return false; - if(all && (index+1 < object->data.vorbis_comment.num_comments)) { - for(i = vorbiscomment_find_entry_from_(object, index+1, (const char *)entry.entry, field_name_length); i >= 0; ) { - if(!FLAC__metadata_object_vorbiscomment_delete_comment(object, (unsigned)i)) + entry = object->data.vorbis_comment.comments[index]; + index++; /* skip over replaced comment */ + if(all && index < object->data.vorbis_comment.num_comments) { + i = vorbiscomment_find_entry_from_(object, index, (const char *)entry.entry, field_name_length); + while(i >= 0) { + index = (unsigned)i; + if(!FLAC__metadata_object_vorbiscomment_delete_comment(object, index)) return false; - if((unsigned)i < object->data.vorbis_comment.num_comments) - i = vorbiscomment_find_entry_from_(object, (unsigned)i, (const char *)entry.entry, field_name_length); + if(index < object->data.vorbis_comment.num_comments) + i = vorbiscomment_find_entry_from_(object, index, (const char *)entry.entry, field_name_length); else i = -1; }