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, AVMetadataTag elem)
    ^
48. {
49.     AVMetadata *m= *pm;

libavformat/metadata.c:49:5: 
47. int av_metadata_set(AVMetadata **pm, AVMetadataTag elem)
48. {
49.     AVMetadata *m= *pm;
        ^
50.     AVMetadataTag *tag= av_metadata_get(m, elem.key, NULL, 0);
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, elem.key, NULL, 0);
        ^
51. 
52.     if(!m)

libavformat/metadata.c:52:9: Taking false branch
50.     AVMetadataTag *tag= av_metadata_get(m, elem.key, NULL, 0);
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:97:1: start of procedure av_realloc()
  95. }
  96. 
  97. void *av_realloc(void *ptr, unsigned int size)
      ^
  98. {
  99. #ifdef CONFIG_MEMALIGN_HACK

libavutil/mem.c:104:8: Taking false branch
  102. 
  103.     /* let's disallow possible ambiguous cases */
  104.     if(size > (INT_MAX-16) )
              ^
  105.         return NULL;
  106. 

libavutil/mem.c:113:5: 
  111.     return (char*)realloc((char*)ptr - diff, size + diff) + diff;
  112. #else
  113.     return realloc(ptr, size);
           ^
  114. #endif
  115. }

libavutil/mem.c:115:1: return from a call to av_realloc
  113.     return realloc(ptr, size);
  114. #endif
  115. }
       ^
  116. 
  117. 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(elem.value){
           ^
67.         elem.key  = av_strdup(elem.key  );
68.         elem.value= av_strdup(elem.value);

libavformat/metadata.c:71:9: Taking true branch
69.         m->elems[m->count++]= elem;
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:128:1: start of procedure av_freep()
  126. }
  127. 
  128. void av_freep(void *arg)
       ^
  129. {
  130.     void **ptr= (void**)arg;

libavutil/mem.c:130:5: 
  128. void av_freep(void *arg)
  129. {
  130.     void **ptr= (void**)arg;
           ^
  131.     av_free(*ptr);
  132.     *ptr = NULL;

libavutil/mem.c:131:5: 
  129. {
  130.     void **ptr= (void**)arg;
  131.     av_free(*ptr);
           ^
  132.     *ptr = NULL;
  133. }

libavutil/mem.c:117:1: start of procedure av_free()
    115. }
    116. 
    117. void av_free(void *ptr)
         ^
    118. {
    119.     /* XXX: this test should not be needed on most libcs */

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

libavutil/mem.c:124:9: 
    122.         free((char*)ptr - ((char*)ptr)[-1]);
    123. #else
    124.         free(ptr);
                 ^
    125. #endif
    126. }

libavutil/mem.c:120:5: 
    118. {
    119.     /* XXX: this test should not be needed on most libcs */
    120.     if (ptr)
             ^
    121. #ifdef CONFIG_MEMALIGN_HACK
    122.         free((char*)ptr - ((char*)ptr)[-1]);

libavutil/mem.c:126:1: return from a call to av_free
    124.         free(ptr);
    125. #endif
    126. }
         ^
    127. 
    128. void av_freep(void *arg)

libavutil/mem.c:132:5: 
  130.     void **ptr= (void**)arg;
  131.     av_free(*ptr);
  132.     *ptr = NULL;
           ^
  133. }
  134. 

libavutil/mem.c:133:1: return from a call to av_freep
  131.     av_free(*ptr);
  132.     *ptr = NULL;
  133. }
       ^
  134. 
  135. void *av_mallocz(unsigned int size)

int av_metadata_set(AVMetadata **pm, AVMetadataTag elem)
{
    AVMetadata *m= *pm;
    AVMetadataTag *tag= av_metadata_get(m, elem.key, NULL, 0);
    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(elem.value){
        elem.key  = av_strdup(elem.key  );
        elem.value= av_strdup(elem.value);
        m->elems[m->count++]= elem;
    }
    if(!m->count)
        av_freep(pm);
    return 0;
}
['int av_metadata_set(AVMetadata **pm, AVMetadataTag elem)\n{\n    AVMetadata *m= *pm;\n    AVMetadataTag *tag= av_metadata_get(m, elem.key, NULL, 0);\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(elem.value){\n        elem.key  = av_strdup(elem.key  );\n        elem.value= av_strdup(elem.value);\n        m->elems[m->count++]= elem;\n    }\n    if(!m->count)\n        av_freep(pm);\n    return 0;\n}', 'void *av_realloc(void *ptr, unsigned int size)\n{\n#ifdef CONFIG_MEMALIGN_HACK\n    int diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#ifdef 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#ifdef CONFIG_MEMALIGN_HACK\n        free((char*)ptr - ((char*)ptr)[-1]);\n#else\n        free(ptr);\n#endif\n}']