In the case of most calls to end_ebml_master, the target is within the current 
segment, but in this case, it's in the first segment or header file, so if the 
context was marked as non-seekable manually (as in segment.c), avio_seek will 
ignore that and execute it anyway. This is fine in other uses of 
end_ebml_master, since both the current and target position are within the 
current segment, but breaks when ending mkv->segment, since `master.pos` refers 
to an offset in the first segment. So instead of failing the seek and 
returning, we end up seeking to an early point in the last segment, overwriting 
8 unrelated bytes, and jumping back.

> On Mar 29, 2015, at 11:29, Michael Niedermayer <michae...@gmx.at> wrote:
> 
> On Sat, Mar 28, 2015 at 07:25:21PM -0600, Rodger Combs wrote:
>> ---
>> libavformat/matroskaenc.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
>> index 6b2e390..c242a0e 100644
>> --- a/libavformat/matroskaenc.c
>> +++ b/libavformat/matroskaenc.c
>> @@ -1948,9 +1948,9 @@ static int mkv_write_trailer(AVFormatContext *s)
>>         put_ebml_float(pb, MATROSKA_ID_DURATION, mkv->duration);
>> 
>>         avio_seek(pb, currentpos, SEEK_SET);
>> +        end_ebml_master(pb, mkv->segment);
>>     }
>> 
>> -    end_ebml_master(pb, mkv->segment);
> 
> the change should be ok but
> why exactly does this fail ?
> 
> if the output isnt seekable avio_seek() would fail and end_ebml_master
> would return with just the failed seek.
> why does this cause a problem ?
> 
> [...]
> 
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> During times of universal deceit, telling the truth becomes a
> revolutionary act. -- George Orwell
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org <mailto:ffmpeg-devel@ffmpeg.org>
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel 
> <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to