libavformat/metadata.c:72: error: Memory Leak
  memory dynamically allocated by call to `av_realloc()` at line 60, column 29 is not reachable after line 72, column 9.

libavformat/metadata.c:47:1: start of procedure av_metadata_set()
45. }
46. 
47. int av_metadata_set(AVMetadata **pm, const char *key, const char *value)
    ^
48. {
49.     AVMetadata *m= *pm;

libavformat/metadata.c:49:5: 
47. int av_metadata_set(AVMetadata **pm, const char *key, const char *value)
48. {
49.     AVMetadata *m= *pm;
        ^
50.     AVMetadataTag *tag= av_metadata_get(m, key, NULL, AV_METADATA_MATCH_CASE);
51. 

libavformat/metadata.c:50:5: Skipping av_metadata_get(): empty list of specs
48. {
49.     AVMetadata *m= *pm;
50.     AVMetadataTag *tag= av_metadata_get(m, key, NULL, AV_METADATA_MATCH_CASE);
        ^
51. 
52.     if(!m)

libavformat/metadata.c:52:9: Taking false branch
50.     AVMetadataTag *tag= av_metadata_get(m, key, NULL, AV_METADATA_MATCH_CASE);
51. 
52.     if(!m)
            ^
53.         m=*pm= av_mallocz(sizeof(*m));
54. 

libavformat/metadata.c:55:8: Taking false branch
53.         m=*pm= av_mallocz(sizeof(*m));
54. 
55.     if(tag){
           ^
56.         av_free(tag->value);
57.         av_free(tag->key);

libavformat/metadata.c:60:9: 
58.         *tag= m->elems[--m->count];
59.     }else{
60.         AVMetadataTag *tmp= av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));
            ^
61.         if(tmp){
62.             m->elems= tmp;

libavutil/mem.c:101:1: start of procedure av_realloc()
   99. }
  100. 
  101. void *av_realloc(void *ptr, unsigned int size)
       ^
  102. {
  103. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:108:8: Taking false branch
  106. 
  107.     /* let's disallow possible ambiguous cases */
  108.     if(size > (INT_MAX-16) )
              ^
  109.         return NULL;
  110. 

libavutil/mem.c:117:5: 
  115.     return (char*)realloc((char*)ptr - diff, size + diff) + diff;
  116. #else
  117.     return realloc(ptr, size);
           ^
  118. #endif
  119. }

libavutil/mem.c:119:1: return from a call to av_realloc
  117.     return realloc(ptr, size);
  118. #endif
  119. }
       ^
  120. 
  121. void av_free(void *ptr)

libavformat/metadata.c:61:12: Taking true branch
59.     }else{
60.         AVMetadataTag *tmp= av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));
61.         if(tmp){
               ^
62.             m->elems= tmp;
63.         }else

libavformat/metadata.c:62:13: 
60.         AVMetadataTag *tmp= av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));
61.         if(tmp){
62.             m->elems= tmp;
                ^
63.         }else
64.             return AVERROR(ENOMEM);

libavformat/metadata.c:66:8: Taking false branch
64.             return AVERROR(ENOMEM);
65.     }
66.     if(value){
           ^
67.         m->elems[m->count].key  = av_strdup(key  );
68.         m->elems[m->count].value= av_strdup(value);

libavformat/metadata.c:71:9: Taking true branch
69.         m->count++;
70.     }
71.     if(!m->count)
            ^
72.         av_freep(pm);
73. 

libavformat/metadata.c:72:9: 
70.     }
71.     if(!m->count)
72.         av_freep(pm);
            ^
73. 
74.     return 0;

libavutil/mem.c:132:1: start of procedure av_freep()
  130. }
  131. 
  132. void av_freep(void *arg)
       ^
  133. {
  134.     void **ptr= (void**)arg;

libavutil/mem.c:134:5: 
  132. void av_freep(void *arg)
  133. {
  134.     void **ptr= (void**)arg;
           ^
  135.     av_free(*ptr);
  136.     *ptr = NULL;

libavutil/mem.c:135:5: 
  133. {
  134.     void **ptr= (void**)arg;
  135.     av_free(*ptr);
           ^
  136.     *ptr = NULL;
  137. }

libavutil/mem.c:121:1: start of procedure av_free()
    119. }
    120. 
    121. void av_free(void *ptr)
         ^
    122. {
    123.     /* XXX: this test should not be needed on most libcs */

libavutil/mem.c:124:9: Taking true branch
    122. {
    123.     /* XXX: this test should not be needed on most libcs */
    124.     if (ptr)
                 ^
    125. #if CONFIG_MEMALIGN_HACK
    126.         free((char*)ptr - ((char*)ptr)[-1]);

libavutil/mem.c:128:9: 
    126.         free((char*)ptr - ((char*)ptr)[-1]);
    127. #else
    128.         free(ptr);
                 ^
    129. #endif
    130. }

libavutil/mem.c:124:5: 
    122. {
    123.     /* XXX: this test should not be needed on most libcs */
    124.     if (ptr)
             ^
    125. #if CONFIG_MEMALIGN_HACK
    126.         free((char*)ptr - ((char*)ptr)[-1]);

libavutil/mem.c:130:1: return from a call to av_free
    128.         free(ptr);
    129. #endif
    130. }
         ^
    131. 
    132. void av_freep(void *arg)

libavutil/mem.c:136:5: 
  134.     void **ptr= (void**)arg;
  135.     av_free(*ptr);
  136.     *ptr = NULL;
           ^
  137. }
  138. 

libavutil/mem.c:137:1: return from a call to av_freep
  135.     av_free(*ptr);
  136.     *ptr = NULL;
  137. }
       ^
  138. 
  139. void *av_mallocz(unsigned int size)

int av_metadata_set(AVMetadata **pm, const char *key, const char *value)
{
    AVMetadata *m= *pm;
    AVMetadataTag *tag= av_metadata_get(m, key, NULL, AV_METADATA_MATCH_CASE);
    if(!m)
        m=*pm= av_mallocz(sizeof(*m));
    if(tag){
        av_free(tag->value);
        av_free(tag->key);
        *tag= m->elems[--m->count];
    }else{
        AVMetadataTag *tmp= av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));
        if(tmp){
            m->elems= tmp;
        }else
            return AVERROR(ENOMEM);
    }
    if(value){
        m->elems[m->count].key  = av_strdup(key  );
        m->elems[m->count].value= av_strdup(value);
        m->count++;
    }
    if(!m->count)
        av_freep(pm);
    return 0;
}
['int av_metadata_set(AVMetadata **pm, const char *key, const char *value)\n{\n    AVMetadata *m= *pm;\n    AVMetadataTag *tag= av_metadata_get(m, key, NULL, AV_METADATA_MATCH_CASE);\n    if(!m)\n        m=*pm= av_mallocz(sizeof(*m));\n    if(tag){\n        av_free(tag->value);\n        av_free(tag->key);\n        *tag= m->elems[--m->count];\n    }else{\n        AVMetadataTag *tmp= av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));\n        if(tmp){\n            m->elems= tmp;\n        }else\n            return AVERROR(ENOMEM);\n    }\n    if(value){\n        m->elems[m->count].key  = av_strdup(key  );\n        m->elems[m->count].value= av_strdup(value);\n        m->count++;\n    }\n    if(!m->count)\n        av_freep(pm);\n    return 0;\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}', 'void av_freep(void *arg)\n{\n    void **ptr= (void**)arg;\n    av_free(*ptr);\n    *ptr = NULL;\n}', 'void av_free(void *ptr)\n{\n    if (ptr)\n#if CONFIG_MEMALIGN_HACK\n        free((char*)ptr - ((char*)ptr)[-1]);\n#else\n        free(ptr);\n#endif\n}']