libavutil/buffer.c:161: error: Memory Leak
  memory dynamically allocated by call to `av_realloc()` at line 155, column 25 is not reachable after line 161, column 13.

libavutil/buffer.c:147:1: start of procedure av_buffer_realloc()
145. }
146. 
147. int av_buffer_realloc(AVBufferRef **pbuf, int size)
     ^
148. {
149.     AVBufferRef *buf = *pbuf;

libavutil/buffer.c:149:5: 
147. int av_buffer_realloc(AVBufferRef **pbuf, int size)
148. {
149.     AVBufferRef *buf = *pbuf;
         ^
150.     uint8_t *tmp;
151. 

libavutil/buffer.c:152:10: Taking true branch
150.     uint8_t *tmp;
151. 
152.     if (!buf) {
              ^
153.         /* allocate a new buffer with av_realloc(), so it will be reallocatable
154.          * later */

libavutil/buffer.c:155:9: 
153.         /* allocate a new buffer with av_realloc(), so it will be reallocatable
154.          * later */
155.         uint8_t *data = av_realloc(NULL, size);
             ^
156.         if (!data)
157.             return AVERROR(ENOMEM);

libavutil/mem.c:117:1: start of procedure av_realloc()
  115. }
  116. 
  117. void *av_realloc(void *ptr, size_t size)
       ^
  118. {
  119. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:124:9: Taking false branch
  122. 
  123.     /* let's disallow possibly ambiguous cases */
  124.     if (size > (INT_MAX - 16))
               ^
  125.         return NULL;
  126. 

libavutil/mem.c:136:5: 
  134.     return _aligned_realloc(ptr, size, 32);
  135. #else
  136.     return realloc(ptr, size);
           ^
  137. #endif
  138. }

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

libavutil/buffer.c:156:14: Taking false branch
154.          * later */
155.         uint8_t *data = av_realloc(NULL, size);
156.         if (!data)
                  ^
157.             return AVERROR(ENOMEM);
158. 

libavutil/buffer.c:159:9: Skipping av_buffer_create(): empty list of specs
157.             return AVERROR(ENOMEM);
158. 
159.         buf = av_buffer_create(data, size, av_buffer_default_free, NULL, 0);
             ^
160.         if (!buf) {
161.             av_freep(&data);

libavutil/buffer.c:160:14: Taking true branch
158. 
159.         buf = av_buffer_create(data, size, av_buffer_default_free, NULL, 0);
160.         if (!buf) {
                  ^
161.             av_freep(&data);
162.             return AVERROR(ENOMEM);

libavutil/buffer.c:161:13: Skipping av_freep(): empty list of specs
159.         buf = av_buffer_create(data, size, av_buffer_default_free, NULL, 0);
160.         if (!buf) {
161.             av_freep(&data);
                 ^
162.             return AVERROR(ENOMEM);
163.         }

int av_buffer_realloc(AVBufferRef **pbuf, int size)
{
    AVBufferRef *buf = *pbuf;
    uint8_t *tmp;
    if (!buf) {
        uint8_t *data = av_realloc(NULL, size);
        if (!data)
            return AVERROR(ENOMEM);
        buf = av_buffer_create(data, size, av_buffer_default_free, NULL, 0);
        if (!buf) {
            av_freep(&data);
            return AVERROR(ENOMEM);
        }
        buf->buffer->flags |= BUFFER_FLAG_REALLOCATABLE;
        *pbuf = buf;
        return 0;
    } else if (buf->size == size)
        return 0;
    if (!(buf->buffer->flags & BUFFER_FLAG_REALLOCATABLE) ||
        !av_buffer_is_writable(buf)) {
        AVBufferRef *new = NULL;
        av_buffer_realloc(&new, size);
        if (!new)
            return AVERROR(ENOMEM);
        memcpy(new->data, buf->data, FFMIN(size, buf->size));
        av_buffer_unref(pbuf);
        *pbuf = new;
        return 0;
    }
    tmp = av_realloc(buf->buffer->data, size);
    if (!tmp)
        return AVERROR(ENOMEM);
    buf->buffer->data = buf->data = tmp;
    buf->buffer->size = buf->size = size;
    return 0;
}
['int av_buffer_realloc(AVBufferRef **pbuf, int size)\n{\n    AVBufferRef *buf = *pbuf;\n    uint8_t *tmp;\n    if (!buf) {\n        uint8_t *data = av_realloc(NULL, size);\n        if (!data)\n            return AVERROR(ENOMEM);\n        buf = av_buffer_create(data, size, av_buffer_default_free, NULL, 0);\n        if (!buf) {\n            av_freep(&data);\n            return AVERROR(ENOMEM);\n        }\n        buf->buffer->flags |= BUFFER_FLAG_REALLOCATABLE;\n        *pbuf = buf;\n        return 0;\n    } else if (buf->size == size)\n        return 0;\n    if (!(buf->buffer->flags & BUFFER_FLAG_REALLOCATABLE) ||\n        !av_buffer_is_writable(buf)) {\n        AVBufferRef *new = NULL;\n        av_buffer_realloc(&new, size);\n        if (!new)\n            return AVERROR(ENOMEM);\n        memcpy(new->data, buf->data, FFMIN(size, buf->size));\n        av_buffer_unref(pbuf);\n        *pbuf = new;\n        return 0;\n    }\n    tmp = av_realloc(buf->buffer->data, size);\n    if (!tmp)\n        return AVERROR(ENOMEM);\n    buf->buffer->data = buf->data = tmp;\n    buf->buffer->size = buf->size = size;\n    return 0;\n}', 'void *av_realloc(void *ptr, size_t 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)\n        return av_malloc(size);\n    diff = ((char *)ptr)[-1];\n    return (char *)realloc((char *)ptr - diff, size + diff) + diff;\n#elif HAVE_ALIGNED_MALLOC\n    return _aligned_realloc(ptr, size, 32);\n#else\n    return realloc(ptr, size);\n#endif\n}']