libavformat/matroskaenc.c:872: error: Integer Overflow L2
  ([0, 9] - 1):unsigned64 by call to `mkv_write_seekhead`.

libavformat/matroskaenc.c:870:15: Call
868.         ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES    , cuespos);
869.         if (ret < 0) return ret;
870.         ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_SEEKHEAD, second_seekhead);
                   ^
871.         if (ret < 0) return ret;
872.         mkv_write_seekhead(pb, mkv->main_seekhead);

libavformat/matroskaenc.c:267:1: Parameter `seekhead->entries->segmentpos`
  265. }
  266. 
  267. static int mkv_add_seekhead_entry(mkv_seekhead *seekhead, unsigned int elementid, uint64_t filepos)
       ^
  268. {
  269.     mkv_seekhead_entry *entries = seekhead->entries;

libavformat/matroskaenc.c:872:9: Call
870.         ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_SEEKHEAD, second_seekhead);
871.         if (ret < 0) return ret;
872.         mkv_write_seekhead(pb, mkv->main_seekhead);
             ^
873. 
874.         // update the duration

libavformat/matroskaenc.c:294:1: Parameter `seekhead->filepos`
  292.  * @return The file offset where the seekhead was written.
  293.  */
  294. static int64_t mkv_write_seekhead(ByteIOContext *pb, mkv_seekhead *seekhead)
       ^
  295. {
  296.     ebml_master metaseek, seekentry;

libavformat/matroskaenc.c:321:9: Assignment
  319. 
  320.     if (seekhead->reserved_size > 0) {
  321.         uint64_t remaining = seekhead->filepos + seekhead->reserved_size - url_ftell(pb);
               ^
  322.         put_ebml_void(pb, remaining);
  323.         url_fseek(pb, currentpos, SEEK_SET);

libavformat/matroskaenc.c:322:9: Call
  320.     if (seekhead->reserved_size > 0) {
  321.         uint64_t remaining = seekhead->filepos + seekhead->reserved_size - url_ftell(pb);
  322.         put_ebml_void(pb, remaining);
               ^
  323.         url_fseek(pb, currentpos, SEEK_SET);
  324. 

libavformat/matroskaenc.c:189:1: <LHS trace>
187.  * @param size The number of bytes to reserve, which must be at least 2.
188.  */
189. static void put_ebml_void(ByteIOContext *pb, uint64_t size)
     ^
190. {
191.     int64_t currentpos = url_ftell(pb);

libavformat/matroskaenc.c:189:1: Parameter `size`
    187.  * @param size The number of bytes to reserve, which must be at least 2.
    188.  */
    189. static void put_ebml_void(ByteIOContext *pb, uint64_t size)
         ^
    190. {
    191.     int64_t currentpos = url_ftell(pb);

libavformat/matroskaenc.c:200:9: Binary operation: ([0, 9] - 1):unsigned64 by call to `mkv_write_seekhead` 
    198.     // size if possible, 1 byte otherwise
    199.     if (size < 10)
    200.         put_ebml_num(pb, size-1, 0);
                 ^
    201.     else
    202.         put_ebml_num(pb, size-9, 8);

static void put_ebml_void(ByteIOContext *pb, uint64_t size)
{
    int64_t currentpos = url_ftell(pb);
    assert(size >= 2);
    put_ebml_id(pb, EBML_ID_VOID);
    if (size < 10)
        put_ebml_num(pb, size-1, 0);
    else
        put_ebml_num(pb, size-9, 8);
    while(url_ftell(pb) < currentpos + size)
        put_byte(pb, 0);
}
['static int mkv_write_trailer(AVFormatContext *s)\n{\n    MatroskaMuxContext *mkv = s->priv_data;\n    ByteIOContext *pb = s->pb;\n    int64_t currentpos, second_seekhead, cuespos;\n    int ret;\n    end_ebml_master(pb, mkv->cluster);\n    if (!url_is_streamed(pb)) {\n        cuespos = mkv_write_cues(pb, mkv->cues, s->nb_streams);\n        second_seekhead = mkv_write_seekhead(pb, mkv->cluster_seekhead);\n        ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES    , cuespos);\n        if (ret < 0) return ret;\n        ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_SEEKHEAD, second_seekhead);\n        if (ret < 0) return ret;\n        mkv_write_seekhead(pb, mkv->main_seekhead);\n        av_log(s, AV_LOG_DEBUG, "end duration = %" PRIu64 "\\n", mkv->duration);\n        currentpos = url_ftell(pb);\n        url_fseek(pb, mkv->duration_offset, SEEK_SET);\n        put_ebml_float(pb, MATROSKA_ID_DURATION, mkv->duration);\n        if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {\n            uint8_t segment_uid[16];\n            av_md5_final(mkv->md5_ctx, segment_uid);\n            url_fseek(pb, mkv->segment_uid, SEEK_SET);\n            put_ebml_binary(pb, MATROSKA_ID_SEGMENTUID, segment_uid, 16);\n        }\n        url_fseek(pb, currentpos, SEEK_SET);\n    }\n    end_ebml_master(pb, mkv->segment);\n    av_free(mkv->md5_ctx);\n    return 0;\n}', 'static int mkv_add_seekhead_entry(mkv_seekhead *seekhead, unsigned int elementid, uint64_t filepos)\n{\n    mkv_seekhead_entry *entries = seekhead->entries;\n    if (seekhead->max_entries > 0 && seekhead->max_entries <= seekhead->num_entries)\n        return -1;\n    entries = av_realloc(entries, (seekhead->num_entries + 1) * sizeof(mkv_seekhead_entry));\n    if (entries == NULL)\n        return AVERROR(ENOMEM);\n    entries[seekhead->num_entries  ].elementid = elementid;\n    entries[seekhead->num_entries++].segmentpos = filepos - seekhead->segment_offset;\n    seekhead->entries = entries;\n    return 0;\n}', 'static int64_t mkv_write_seekhead(ByteIOContext *pb, mkv_seekhead *seekhead)\n{\n    ebml_master metaseek, seekentry;\n    int64_t currentpos;\n    int i;\n    currentpos = url_ftell(pb);\n    if (seekhead->reserved_size > 0)\n        url_fseek(pb, seekhead->filepos, SEEK_SET);\n    metaseek = start_ebml_master(pb, MATROSKA_ID_SEEKHEAD, seekhead->reserved_size);\n    for (i = 0; i < seekhead->num_entries; i++) {\n        mkv_seekhead_entry *entry = &seekhead->entries[i];\n        seekentry = start_ebml_master(pb, MATROSKA_ID_SEEKENTRY, MAX_SEEKENTRY_SIZE);\n        put_ebml_id(pb, MATROSKA_ID_SEEKID);\n        put_ebml_num(pb, ebml_id_size(entry->elementid), 0);\n        put_ebml_id(pb, entry->elementid);\n        put_ebml_uint(pb, MATROSKA_ID_SEEKPOSITION, entry->segmentpos);\n        end_ebml_master(pb, seekentry);\n    }\n    end_ebml_master(pb, metaseek);\n    if (seekhead->reserved_size > 0) {\n        uint64_t remaining = seekhead->filepos + seekhead->reserved_size - url_ftell(pb);\n        put_ebml_void(pb, remaining);\n        url_fseek(pb, currentpos, SEEK_SET);\n        currentpos = seekhead->filepos;\n    }\n    av_free(seekhead->entries);\n    av_free(seekhead);\n    return currentpos;\n}', 'static void put_ebml_void(ByteIOContext *pb, uint64_t size)\n{\n    int64_t currentpos = url_ftell(pb);\n    assert(size >= 2);\n    put_ebml_id(pb, EBML_ID_VOID);\n    if (size < 10)\n        put_ebml_num(pb, size-1, 0);\n    else\n        put_ebml_num(pb, size-9, 8);\n    while(url_ftell(pb) < currentpos + size)\n        put_byte(pb, 0);\n}']