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

libavformat/matroskaenc.c:1019:15: Call
1017.         cuespos = mkv_write_cues(pb, mkv->cues, s->nb_streams);
1018. 
1019.         ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES    , cuespos);
                    ^
1020.         if (ret < 0) return ret;
1021.         mkv_write_seekhead(pb, mkv->main_seekhead);

libavformat/matroskaenc.c:276:1: Parameter `seekhead->entries->segmentpos`
  274. }
  275. 
  276. static int mkv_add_seekhead_entry(mkv_seekhead *seekhead, unsigned int elementid, uint64_t filepos)
       ^
  277. {
  278.     mkv_seekhead_entry *entries = seekhead->entries;

libavformat/matroskaenc.c:1021:9: Call
1019.         ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES    , cuespos);
1020.         if (ret < 0) return ret;
1021.         mkv_write_seekhead(pb, mkv->main_seekhead);
              ^
1022. 
1023.         // update the duration

libavformat/matroskaenc.c:304:1: Parameter `seekhead->filepos`
  302.  * -1 if an error occurred.
  303.  */
  304. static int64_t mkv_write_seekhead(ByteIOContext *pb, mkv_seekhead *seekhead)
       ^
  305. {
  306.     ebml_master metaseek, seekentry;

libavformat/matroskaenc.c:332:9: Assignment
  330. 
  331.     if (seekhead->reserved_size > 0) {
  332.         uint64_t remaining = seekhead->filepos + seekhead->reserved_size - url_ftell(pb);
               ^
  333.         put_ebml_void(pb, remaining);
  334.         url_fseek(pb, currentpos, SEEK_SET);

libavformat/matroskaenc.c:333:9: Call
  331.     if (seekhead->reserved_size > 0) {
  332.         uint64_t remaining = seekhead->filepos + seekhead->reserved_size - url_ftell(pb);
  333.         put_ebml_void(pb, remaining);
               ^
  334.         url_fseek(pb, currentpos, SEEK_SET);
  335. 

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

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

libavformat/matroskaenc.c:212:9: Binary operation: ([0, 9] - 1):unsigned64 by call to `mkv_write_seekhead` 
    210.     // size if possible, 1 byte otherwise
    211.     if (size < 10)
    212.         put_ebml_num(pb, size-1, 0);
                 ^
    213.     else
    214.         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, cuespos;\n    int ret;\n    if (mkv->cur_audio_pkt.size > 0) {\n        ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt);\n        mkv->cur_audio_pkt.size = 0;\n        if (ret < 0) {\n            av_log(s, AV_LOG_ERROR, "Could not write cached audio packet ret:%d\\n", ret);\n            return ret;\n        }\n    }\n    if (mkv->dyn_bc) {\n        end_ebml_master(mkv->dyn_bc, mkv->cluster);\n        mkv_flush_dynbuf(s);\n    } else if (mkv->cluster_pos) {\n        end_ebml_master(pb, mkv->cluster);\n    }\n    if (!url_is_streamed(pb)) {\n        cuespos = mkv_write_cues(pb, mkv->cues, s->nb_streams);\n        ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES    , cuespos);\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        url_fseek(pb, currentpos, SEEK_SET);\n    }\n    end_ebml_master(pb, mkv->segment);\n    av_free(mkv->tracks);\n    av_destruct_packet(&mkv->cur_audio_pkt);\n    put_flush_packet(pb);\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        if (url_fseek(pb, seekhead->filepos, SEEK_SET) < 0)\n            return -1;\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}']