libavformat/matroskadec.c:926: error: Memory Leak
  memory dynamically allocated by call to `av_realloc()` at line 926, column 24 is not reachable after line 926, column 13.

libavformat/matroskadec.c:890:1: start of procedure matroska_decode_buffer()
888. }
889. 
890. static int matroska_decode_buffer(uint8_t** buf, int* buf_size,
     ^
891.                                   MatroskaTrack *track)
892. {

libavformat/matroskadec.c:893:5: 
891.                                   MatroskaTrack *track)
892. {
893.     MatroskaTrackEncoding *encodings = track->encodings.elem;
         ^
894.     uint8_t* data = *buf;
895.     int isize = *buf_size;

libavformat/matroskadec.c:894:5: 
892. {
893.     MatroskaTrackEncoding *encodings = track->encodings.elem;
894.     uint8_t* data = *buf;
         ^
895.     int isize = *buf_size;
896.     uint8_t* pkt_data = NULL;

libavformat/matroskadec.c:895:5: 
893.     MatroskaTrackEncoding *encodings = track->encodings.elem;
894.     uint8_t* data = *buf;
895.     int isize = *buf_size;
         ^
896.     uint8_t* pkt_data = NULL;
897.     int pkt_size = isize;

libavformat/matroskadec.c:896:5: 
894.     uint8_t* data = *buf;
895.     int isize = *buf_size;
896.     uint8_t* pkt_data = NULL;
         ^
897.     int pkt_size = isize;
898.     int result = 0;

libavformat/matroskadec.c:897:5: 
895.     int isize = *buf_size;
896.     uint8_t* pkt_data = NULL;
897.     int pkt_size = isize;
         ^
898.     int result = 0;
899.     int olen;

libavformat/matroskadec.c:898:5: 
896.     uint8_t* pkt_data = NULL;
897.     int pkt_size = isize;
898.     int result = 0;
         ^
899.     int olen;
900. 

libavformat/matroskadec.c:901:9: Taking false branch
899.     int olen;
900. 
901.     if (pkt_size >= 10000000)
             ^
902.         return -1;
903. 

libavformat/matroskadec.c:904:5: 
902.         return -1;
903. 
904.     switch (encodings[0].compression.algo) {
         ^
905.     case MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP:
906.         return encodings[0].compression.settings.size;

libavformat/matroskadec.c:905:5: Switch condition is false. Skipping switch case
903. 
904.     switch (encodings[0].compression.algo) {
905.     case MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP:
         ^
906.         return encodings[0].compression.settings.size;
907.     case MATROSKA_TRACK_ENCODING_COMP_LZO:

libavformat/matroskadec.c:907:5: Switch condition is false. Skipping switch case
905.     case MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP:
906.         return encodings[0].compression.settings.size;
907.     case MATROSKA_TRACK_ENCODING_COMP_LZO:
         ^
908.         do {
909.             olen = pkt_size *= 3;

libavformat/matroskadec.c:918:5: Switch condition is true. Entering switch case
916.         break;
917. #if CONFIG_ZLIB
918.     case MATROSKA_TRACK_ENCODING_COMP_ZLIB: {
         ^
919.         z_stream zstream = {0};
920.         if (inflateInit(&zstream) != Z_OK)

libavformat/matroskadec.c:919:9: 
917. #if CONFIG_ZLIB
918.     case MATROSKA_TRACK_ENCODING_COMP_ZLIB: {
919.         z_stream zstream = {0};
             ^
920.         if (inflateInit(&zstream) != Z_OK)
921.             return -1;

libavformat/matroskadec.c:920:13: Taking false branch
918.     case MATROSKA_TRACK_ENCODING_COMP_ZLIB: {
919.         z_stream zstream = {0};
920.         if (inflateInit(&zstream) != Z_OK)
                 ^
921.             return -1;
922.         zstream.next_in = data;

libavformat/matroskadec.c:922:9: 
920.         if (inflateInit(&zstream) != Z_OK)
921.             return -1;
922.         zstream.next_in = data;
             ^
923.         zstream.avail_in = isize;
924.         do {

libavformat/matroskadec.c:923:9: 
921.             return -1;
922.         zstream.next_in = data;
923.         zstream.avail_in = isize;
             ^
924.         do {
925.             pkt_size *= 3;

libavformat/matroskadec.c:925:13: 
923.         zstream.avail_in = isize;
924.         do {
925.             pkt_size *= 3;
                 ^
926.             pkt_data = av_realloc(pkt_data, pkt_size);
927.             zstream.avail_out = pkt_size - zstream.total_out;

libavformat/matroskadec.c:926:13: 
924.         do {
925.             pkt_size *= 3;
926.             pkt_data = av_realloc(pkt_data, pkt_size);
                 ^
927.             zstream.avail_out = pkt_size - zstream.total_out;
928.             zstream.next_out = pkt_data + zstream.total_out;

libavutil/mem.c:119:1: start of procedure av_realloc()
  117. }
  118. 
  119. void *av_realloc(void *ptr, unsigned int size)
       ^
  120. {
  121. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:126:8: Taking false branch
  124. 
  125.     /* let's disallow possible ambiguous cases */
  126.     if(size > (INT_MAX-16) )
              ^
  127.         return NULL;
  128. 

libavutil/mem.c:135:5: 
  133.     return (char*)realloc((char*)ptr - diff, size + diff) + diff;
  134. #else
  135.     return realloc(ptr, size);
           ^
  136. #endif
  137. }

libavutil/mem.c:137:1: return from a call to av_realloc
  135.     return realloc(ptr, size);
  136. #endif
  137. }
       ^
  138. 
  139. void av_free(void *ptr)

libavformat/matroskadec.c:927:13: 
925.             pkt_size *= 3;
926.             pkt_data = av_realloc(pkt_data, pkt_size);
927.             zstream.avail_out = pkt_size - zstream.total_out;
                 ^
928.             zstream.next_out = pkt_data + zstream.total_out;
929.             result = inflate(&zstream, Z_NO_FLUSH);

libavformat/matroskadec.c:928:13: 
926.             pkt_data = av_realloc(pkt_data, pkt_size);
927.             zstream.avail_out = pkt_size - zstream.total_out;
928.             zstream.next_out = pkt_data + zstream.total_out;
                 ^
929.             result = inflate(&zstream, Z_NO_FLUSH);
930.         } while (result==Z_OK && pkt_size<10000000);

libavformat/matroskadec.c:929:13: Skipping inflate(): method has no implementation
927.             zstream.avail_out = pkt_size - zstream.total_out;
928.             zstream.next_out = pkt_data + zstream.total_out;
929.             result = inflate(&zstream, Z_NO_FLUSH);
                 ^
930.         } while (result==Z_OK && pkt_size<10000000);
931.         pkt_size = zstream.total_out;

libavformat/matroskadec.c:930:18: Loop condition is true. Entering loop body
928.             zstream.next_out = pkt_data + zstream.total_out;
929.             result = inflate(&zstream, Z_NO_FLUSH);
930.         } while (result==Z_OK && pkt_size<10000000);
                      ^
931.         pkt_size = zstream.total_out;
932.         inflateEnd(&zstream);

libavformat/matroskadec.c:930:34: Loop condition is true. Entering loop body
928.             zstream.next_out = pkt_data + zstream.total_out;
929.             result = inflate(&zstream, Z_NO_FLUSH);
930.         } while (result==Z_OK && pkt_size<10000000);
                                      ^
931.         pkt_size = zstream.total_out;
932.         inflateEnd(&zstream);

libavformat/matroskadec.c:925:13: 
923.         zstream.avail_in = isize;
924.         do {
925.             pkt_size *= 3;
                 ^
926.             pkt_data = av_realloc(pkt_data, pkt_size);
927.             zstream.avail_out = pkt_size - zstream.total_out;

libavformat/matroskadec.c:926:13: 
924.         do {
925.             pkt_size *= 3;
926.             pkt_data = av_realloc(pkt_data, pkt_size);
                 ^
927.             zstream.avail_out = pkt_size - zstream.total_out;
928.             zstream.next_out = pkt_data + zstream.total_out;

libavutil/mem.c:119:1: start of procedure av_realloc()
  117. }
  118. 
  119. void *av_realloc(void *ptr, unsigned int size)
       ^
  120. {
  121. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:126:8: Taking true branch
  124. 
  125.     /* let's disallow possible ambiguous cases */
  126.     if(size > (INT_MAX-16) )
              ^
  127.         return NULL;
  128. 

libavutil/mem.c:127:9: 
  125.     /* let's disallow possible ambiguous cases */
  126.     if(size > (INT_MAX-16) )
  127.         return NULL;
               ^
  128. 
  129. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:137:1: return from a call to av_realloc
  135.     return realloc(ptr, size);
  136. #endif
  137. }
       ^
  138. 
  139. void av_free(void *ptr)

static int matroska_decode_buffer(uint8_t** buf, int* buf_size,
                                  MatroskaTrack *track)
{
    MatroskaTrackEncoding *encodings = track->encodings.elem;
    uint8_t* data = *buf;
    int isize = *buf_size;
    uint8_t* pkt_data = NULL;
    int pkt_size = isize;
    int result = 0;
    int olen;
    if (pkt_size >= 10000000)
        return -1;
    switch (encodings[0].compression.algo) {
    case MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP:
        return encodings[0].compression.settings.size;
    case MATROSKA_TRACK_ENCODING_COMP_LZO:
        do {
            olen = pkt_size *= 3;
            pkt_data = av_realloc(pkt_data, pkt_size+AV_LZO_OUTPUT_PADDING);
            result = av_lzo1x_decode(pkt_data, &olen, data, &isize);
        } while (result==AV_LZO_OUTPUT_FULL && pkt_size<10000000);
        if (result)
            goto failed;
        pkt_size -= olen;
        break;
#if CONFIG_ZLIB
    case MATROSKA_TRACK_ENCODING_COMP_ZLIB: {
        z_stream zstream = {0};
        if (inflateInit(&zstream) != Z_OK)
            return -1;
        zstream.next_in = data;
        zstream.avail_in = isize;
        do {
            pkt_size *= 3;
            pkt_data = av_realloc(pkt_data, pkt_size);
            zstream.avail_out = pkt_size - zstream.total_out;
            zstream.next_out = pkt_data + zstream.total_out;
            result = inflate(&zstream, Z_NO_FLUSH);
        } while (result==Z_OK && pkt_size<10000000);
        pkt_size = zstream.total_out;
        inflateEnd(&zstream);
        if (result != Z_STREAM_END)
            goto failed;
        break;
    }
#endif
#if CONFIG_BZLIB
    case MATROSKA_TRACK_ENCODING_COMP_BZLIB: {
        bz_stream bzstream = {0};
        if (BZ2_bzDecompressInit(&bzstream, 0, 0) != BZ_OK)
            return -1;
        bzstream.next_in = data;
        bzstream.avail_in = isize;
        do {
            pkt_size *= 3;
            pkt_data = av_realloc(pkt_data, pkt_size);
            bzstream.avail_out = pkt_size - bzstream.total_out_lo32;
            bzstream.next_out = pkt_data + bzstream.total_out_lo32;
            result = BZ2_bzDecompress(&bzstream);
        } while (result==BZ_OK && pkt_size<10000000);
        pkt_size = bzstream.total_out_lo32;
        BZ2_bzDecompressEnd(&bzstream);
        if (result != BZ_STREAM_END)
            goto failed;
        break;
    }
#endif
    default:
        return -1;
    }
    *buf = pkt_data;
    *buf_size = pkt_size;
    return 0;
 failed:
    av_free(pkt_data);
    return -1;
}
['static int matroska_decode_buffer(uint8_t** buf, int* buf_size,\n                                  MatroskaTrack *track)\n{\n    MatroskaTrackEncoding *encodings = track->encodings.elem;\n    uint8_t* data = *buf;\n    int isize = *buf_size;\n    uint8_t* pkt_data = NULL;\n    int pkt_size = isize;\n    int result = 0;\n    int olen;\n    if (pkt_size >= 10000000)\n        return -1;\n    switch (encodings[0].compression.algo) {\n    case MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP:\n        return encodings[0].compression.settings.size;\n    case MATROSKA_TRACK_ENCODING_COMP_LZO:\n        do {\n            olen = pkt_size *= 3;\n            pkt_data = av_realloc(pkt_data, pkt_size+AV_LZO_OUTPUT_PADDING);\n            result = av_lzo1x_decode(pkt_data, &olen, data, &isize);\n        } while (result==AV_LZO_OUTPUT_FULL && pkt_size<10000000);\n        if (result)\n            goto failed;\n        pkt_size -= olen;\n        break;\n#if CONFIG_ZLIB\n    case MATROSKA_TRACK_ENCODING_COMP_ZLIB: {\n        z_stream zstream = {0};\n        if (inflateInit(&zstream) != Z_OK)\n            return -1;\n        zstream.next_in = data;\n        zstream.avail_in = isize;\n        do {\n            pkt_size *= 3;\n            pkt_data = av_realloc(pkt_data, pkt_size);\n            zstream.avail_out = pkt_size - zstream.total_out;\n            zstream.next_out = pkt_data + zstream.total_out;\n            result = inflate(&zstream, Z_NO_FLUSH);\n        } while (result==Z_OK && pkt_size<10000000);\n        pkt_size = zstream.total_out;\n        inflateEnd(&zstream);\n        if (result != Z_STREAM_END)\n            goto failed;\n        break;\n    }\n#endif\n#if CONFIG_BZLIB\n    case MATROSKA_TRACK_ENCODING_COMP_BZLIB: {\n        bz_stream bzstream = {0};\n        if (BZ2_bzDecompressInit(&bzstream, 0, 0) != BZ_OK)\n            return -1;\n        bzstream.next_in = data;\n        bzstream.avail_in = isize;\n        do {\n            pkt_size *= 3;\n            pkt_data = av_realloc(pkt_data, pkt_size);\n            bzstream.avail_out = pkt_size - bzstream.total_out_lo32;\n            bzstream.next_out = pkt_data + bzstream.total_out_lo32;\n            result = BZ2_bzDecompress(&bzstream);\n        } while (result==BZ_OK && pkt_size<10000000);\n        pkt_size = bzstream.total_out_lo32;\n        BZ2_bzDecompressEnd(&bzstream);\n        if (result != BZ_STREAM_END)\n            goto failed;\n        break;\n    }\n#endif\n    default:\n        return -1;\n    }\n    *buf = pkt_data;\n    *buf_size = pkt_size;\n    return 0;\n failed:\n    av_free(pkt_data);\n    return -1;\n}', 'void *av_realloc(void *ptr, unsigned int size)\n{\n#if CONFIG_MEMALIGN_HACK\n    int diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    if(!ptr) return av_malloc(size);\n    diff= ((char*)ptr)[-1];\n    return (char*)realloc((char*)ptr - diff, size + diff) + diff;\n#else\n    return realloc(ptr, size);\n#endif\n}']