libavformat/icecast.c:117: error: Memory Leak
  memory dynamically allocated by call to `cat_header()` at line 115, column 15 is not reachable after line 117, column 5.

libavformat/icecast.c:99:1: start of procedure icecast_open()
 97. }
 98. 
 99. static int icecast_open(URLContext *h, const char *uri, int flags)
     ^
100. {
101.     IcecastContext *s = h->priv_data;

libavformat/icecast.c:101:5: 
 99. static int icecast_open(URLContext *h, const char *uri, int flags)
100. {
101.     IcecastContext *s = h->priv_data;
         ^
102. 
103.     // Dict to set options that we pass to the HTTP protocol

libavformat/icecast.c:104:5: 
102. 
103.     // Dict to set options that we pass to the HTTP protocol
104.     AVDictionary *opt_dict = NULL;
         ^
105. 
106.     // URI part variables

libavformat/icecast.c:108:5: 
106.     // URI part variables
107.     char h_url[1024], host[1024], auth[1024], path[1024];
108.     char *headers = NULL, *user = NULL;
         ^
109.     int port, ret;
110. 

libavformat/icecast.c:111:9: Taking false branch
109.     int port, ret;
110. 
111.     if (flags & AVIO_FLAG_READ)
             ^
112.         return AVERROR(ENOSYS);
113. 

libavformat/icecast.c:115:5: 
113. 
114.     // Build header strings
115.     headers = cat_header(headers, "Ice-Name", s->name);
         ^
116.     headers = cat_header(headers, "Ice-Description", s->description);
117.     headers = cat_header(headers, "Ice-URL", s->url);

libavformat/icecast.c:68:1: start of procedure cat_header()
  66. 
  67. 
  68. static char *cat_header(char buf[], const char key[], const char value[])
      ^
  69. {
  70.     if (NOT_EMPTY(value)) {

libavformat/icecast.c:70:9: Taking true branch
  68. static char *cat_header(char buf[], const char key[], const char value[])
  69. {
  70.     if (NOT_EMPTY(value)) {
              ^
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;

libavformat/icecast.c:70:9: Taking true branch
  68. static char *cat_header(char buf[], const char key[], const char value[])
  69. {
  70.     if (NOT_EMPTY(value)) {
              ^
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;

libavformat/icecast.c:71:9: 
  69. {
  70.     if (NOT_EMPTY(value)) {
  71.         int len = strlen(key) + strlen(value) + 5;
              ^
  72.         int is_first = !buf;
  73.         char *tmp = NULL;

libavformat/icecast.c:72:25: Condition is false
  70.     if (NOT_EMPTY(value)) {
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;
                              ^
  73.         char *tmp = NULL;
  74. 

libavformat/icecast.c:72:24: 
  70.     if (NOT_EMPTY(value)) {
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;
                             ^
  73.         char *tmp = NULL;
  74. 

libavformat/icecast.c:72:9: 
  70.     if (NOT_EMPTY(value)) {
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;
              ^
  73.         char *tmp = NULL;
  74. 

libavformat/icecast.c:73:9: 
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;
  73.         char *tmp = NULL;
              ^
  74. 
  75.         if (buf)

libavformat/icecast.c:75:13: Taking false branch
  73.         char *tmp = NULL;
  74. 
  75.         if (buf)
                  ^
  76.             len += strlen(buf);
  77.         if (!(tmp = av_realloc(buf, len))) {

libavformat/icecast.c:77:15: 
  75.         if (buf)
  76.             len += strlen(buf);
  77.         if (!(tmp = av_realloc(buf, len))) {
                    ^
  78.             av_freep(&buf);
  79.             return NULL;

libavutil/mem.c:107:1: start of procedure av_realloc()
    105. }
    106. 
    107. void *av_realloc(void *ptr, size_t size)
         ^
    108. {
    109.     /* let's disallow possibly ambiguous cases */

libavutil/mem.c:110:9: Taking false branch
    108. {
    109.     /* let's disallow possibly ambiguous cases */
    110.     if (size > (INT_MAX - 16))
                 ^
    111.         return NULL;
    112. 

libavutil/mem.c:116:5: 
    114.     return _aligned_realloc(ptr, size, 32);
    115. #else
    116.     return realloc(ptr, size);
             ^
    117. #endif
    118. }

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

libavformat/icecast.c:77:15: Taking false branch
  75.         if (buf)
  76.             len += strlen(buf);
  77.         if (!(tmp = av_realloc(buf, len))) {
                    ^
  78.             av_freep(&buf);
  79.             return NULL;

libavformat/icecast.c:81:13: 
  79.             return NULL;
  80.         } else {
  81.             buf = tmp;
                  ^
  82.         }
  83.         if (is_first)

libavformat/icecast.c:83:13: Taking true branch
  81.             buf = tmp;
  82.         }
  83.         if (is_first)
                  ^
  84.             *buf = '\0';
  85. 

libavformat/icecast.c:84:13: 
  82.         }
  83.         if (is_first)
  84.             *buf = '\0';
                  ^
  85. 
  86.         av_strlcatf(buf, len, "%s: %s\r\n", key, value);

libavformat/icecast.c:86:9: 
  84.             *buf = '\0';
  85. 
  86.         av_strlcatf(buf, len, "%s: %s\r\n", key, value);
              ^
  87.     }
  88.     return buf;

libavutil/avstring.c:99:1: start of procedure av_strlcatf()
     97. }
     98. 
     99. size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...)
         ^
    100. {
    101.     int len = strlen(dst);

libavutil/avstring.c:101:5: 
     99. size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...)
    100. {
    101.     int len = strlen(dst);
             ^
    102.     va_list vl;
    103. 

libavutil/avstring.c:104:5: 
    102.     va_list vl;
    103. 
    104.     va_start(vl, fmt);
             ^
    105.     len += vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl);
    106.     va_end(vl);

libavutil/avstring.c:105:33: Condition is true
    103. 
    104.     va_start(vl, fmt);
    105.     len += vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl);
                                         ^
    106.     va_end(vl);
    107. 

libavutil/avstring.c:105:5: 
    103. 
    104.     va_start(vl, fmt);
    105.     len += vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl);
             ^
    106.     va_end(vl);
    107. 

libavutil/avstring.c:106:5: 
    104.     va_start(vl, fmt);
    105.     len += vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl);
    106.     va_end(vl);
             ^
    107. 
    108.     return len;

libavutil/avstring.c:108:5: 
    106.     va_end(vl);
    107. 
    108.     return len;
             ^
    109. }
    110. 

libavutil/avstring.c:109:1: return from a call to av_strlcatf
    107. 
    108.     return len;
    109. }
         ^
    110. 
    111. char *av_d2str(double d)

libavformat/icecast.c:88:5: 
  86.         av_strlcatf(buf, len, "%s: %s\r\n", key, value);
  87.     }
  88.     return buf;
          ^
  89. }
  90. 

libavformat/icecast.c:89:1: return from a call to cat_header
  87.     }
  88.     return buf;
  89. }
      ^
  90. 
  91. static int icecast_close(URLContext *h)

libavformat/icecast.c:116:5: 
114.     // Build header strings
115.     headers = cat_header(headers, "Ice-Name", s->name);
116.     headers = cat_header(headers, "Ice-Description", s->description);
         ^
117.     headers = cat_header(headers, "Ice-URL", s->url);
118.     headers = cat_header(headers, "Ice-Genre", s->genre);

libavformat/icecast.c:68:1: start of procedure cat_header()
  66. 
  67. 
  68. static char *cat_header(char buf[], const char key[], const char value[])
      ^
  69. {
  70.     if (NOT_EMPTY(value)) {

libavformat/icecast.c:70:9: Taking true branch
  68. static char *cat_header(char buf[], const char key[], const char value[])
  69. {
  70.     if (NOT_EMPTY(value)) {
              ^
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;

libavformat/icecast.c:70:9: Taking true branch
  68. static char *cat_header(char buf[], const char key[], const char value[])
  69. {
  70.     if (NOT_EMPTY(value)) {
              ^
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;

libavformat/icecast.c:71:9: 
  69. {
  70.     if (NOT_EMPTY(value)) {
  71.         int len = strlen(key) + strlen(value) + 5;
              ^
  72.         int is_first = !buf;
  73.         char *tmp = NULL;

libavformat/icecast.c:72:25: Condition is true
  70.     if (NOT_EMPTY(value)) {
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;
                              ^
  73.         char *tmp = NULL;
  74. 

libavformat/icecast.c:72:24: 
  70.     if (NOT_EMPTY(value)) {
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;
                             ^
  73.         char *tmp = NULL;
  74. 

libavformat/icecast.c:72:9: 
  70.     if (NOT_EMPTY(value)) {
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;
              ^
  73.         char *tmp = NULL;
  74. 

libavformat/icecast.c:73:9: 
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;
  73.         char *tmp = NULL;
              ^
  74. 
  75.         if (buf)

libavformat/icecast.c:75:13: Taking true branch
  73.         char *tmp = NULL;
  74. 
  75.         if (buf)
                  ^
  76.             len += strlen(buf);
  77.         if (!(tmp = av_realloc(buf, len))) {

libavformat/icecast.c:76:13: 
  74. 
  75.         if (buf)
  76.             len += strlen(buf);
                  ^
  77.         if (!(tmp = av_realloc(buf, len))) {
  78.             av_freep(&buf);

libavformat/icecast.c:77:15: 
  75.         if (buf)
  76.             len += strlen(buf);
  77.         if (!(tmp = av_realloc(buf, len))) {
                    ^
  78.             av_freep(&buf);
  79.             return NULL;

libavutil/mem.c:107:1: start of procedure av_realloc()
    105. }
    106. 
    107. void *av_realloc(void *ptr, size_t size)
         ^
    108. {
    109.     /* let's disallow possibly ambiguous cases */

libavutil/mem.c:110:9: Taking false branch
    108. {
    109.     /* let's disallow possibly ambiguous cases */
    110.     if (size > (INT_MAX - 16))
                 ^
    111.         return NULL;
    112. 

libavutil/mem.c:116:5: 
    114.     return _aligned_realloc(ptr, size, 32);
    115. #else
    116.     return realloc(ptr, size);
             ^
    117. #endif
    118. }

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

libavformat/icecast.c:77:15: Taking false branch
  75.         if (buf)
  76.             len += strlen(buf);
  77.         if (!(tmp = av_realloc(buf, len))) {
                    ^
  78.             av_freep(&buf);
  79.             return NULL;

libavformat/icecast.c:81:13: 
  79.             return NULL;
  80.         } else {
  81.             buf = tmp;
                  ^
  82.         }
  83.         if (is_first)

libavformat/icecast.c:83:13: Taking false branch
  81.             buf = tmp;
  82.         }
  83.         if (is_first)
                  ^
  84.             *buf = '\0';
  85. 

libavformat/icecast.c:86:9: 
  84.             *buf = '\0';
  85. 
  86.         av_strlcatf(buf, len, "%s: %s\r\n", key, value);
              ^
  87.     }
  88.     return buf;

libavutil/avstring.c:99:1: start of procedure av_strlcatf()
     97. }
     98. 
     99. size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...)
         ^
    100. {
    101.     int len = strlen(dst);

libavutil/avstring.c:101:5: 
     99. size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...)
    100. {
    101.     int len = strlen(dst);
             ^
    102.     va_list vl;
    103. 

libavutil/avstring.c:104:5: 
    102.     va_list vl;
    103. 
    104.     va_start(vl, fmt);
             ^
    105.     len += vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl);
    106.     va_end(vl);

libavutil/avstring.c:105:33: Condition is true
    103. 
    104.     va_start(vl, fmt);
    105.     len += vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl);
                                         ^
    106.     va_end(vl);
    107. 

libavutil/avstring.c:105:5: 
    103. 
    104.     va_start(vl, fmt);
    105.     len += vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl);
             ^
    106.     va_end(vl);
    107. 

libavutil/avstring.c:106:5: 
    104.     va_start(vl, fmt);
    105.     len += vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl);
    106.     va_end(vl);
             ^
    107. 
    108.     return len;

libavutil/avstring.c:108:5: 
    106.     va_end(vl);
    107. 
    108.     return len;
             ^
    109. }
    110. 

libavutil/avstring.c:109:1: return from a call to av_strlcatf
    107. 
    108.     return len;
    109. }
         ^
    110. 
    111. char *av_d2str(double d)

libavformat/icecast.c:88:5: 
  86.         av_strlcatf(buf, len, "%s: %s\r\n", key, value);
  87.     }
  88.     return buf;
          ^
  89. }
  90. 

libavformat/icecast.c:89:1: return from a call to cat_header
  87.     }
  88.     return buf;
  89. }
      ^
  90. 
  91. static int icecast_close(URLContext *h)

libavformat/icecast.c:117:5: 
115.     headers = cat_header(headers, "Ice-Name", s->name);
116.     headers = cat_header(headers, "Ice-Description", s->description);
117.     headers = cat_header(headers, "Ice-URL", s->url);
         ^
118.     headers = cat_header(headers, "Ice-Genre", s->genre);
119.     headers = cat_header(headers, "Ice-Public", s->public ? "1" : "0");

libavformat/icecast.c:68:1: start of procedure cat_header()
  66. 
  67. 
  68. static char *cat_header(char buf[], const char key[], const char value[])
      ^
  69. {
  70.     if (NOT_EMPTY(value)) {

libavformat/icecast.c:70:9: Taking true branch
  68. static char *cat_header(char buf[], const char key[], const char value[])
  69. {
  70.     if (NOT_EMPTY(value)) {
              ^
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;

libavformat/icecast.c:70:9: Taking true branch
  68. static char *cat_header(char buf[], const char key[], const char value[])
  69. {
  70.     if (NOT_EMPTY(value)) {
              ^
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;

libavformat/icecast.c:71:9: 
  69. {
  70.     if (NOT_EMPTY(value)) {
  71.         int len = strlen(key) + strlen(value) + 5;
              ^
  72.         int is_first = !buf;
  73.         char *tmp = NULL;

libavformat/icecast.c:72:25: Condition is true
  70.     if (NOT_EMPTY(value)) {
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;
                              ^
  73.         char *tmp = NULL;
  74. 

libavformat/icecast.c:72:24: 
  70.     if (NOT_EMPTY(value)) {
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;
                             ^
  73.         char *tmp = NULL;
  74. 

libavformat/icecast.c:72:9: 
  70.     if (NOT_EMPTY(value)) {
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;
              ^
  73.         char *tmp = NULL;
  74. 

libavformat/icecast.c:73:9: 
  71.         int len = strlen(key) + strlen(value) + 5;
  72.         int is_first = !buf;
  73.         char *tmp = NULL;
              ^
  74. 
  75.         if (buf)

libavformat/icecast.c:75:13: Taking true branch
  73.         char *tmp = NULL;
  74. 
  75.         if (buf)
                  ^
  76.             len += strlen(buf);
  77.         if (!(tmp = av_realloc(buf, len))) {

libavformat/icecast.c:76:13: 
  74. 
  75.         if (buf)
  76.             len += strlen(buf);
                  ^
  77.         if (!(tmp = av_realloc(buf, len))) {
  78.             av_freep(&buf);

libavformat/icecast.c:77:15: 
  75.         if (buf)
  76.             len += strlen(buf);
  77.         if (!(tmp = av_realloc(buf, len))) {
                    ^
  78.             av_freep(&buf);
  79.             return NULL;

libavutil/mem.c:107:1: start of procedure av_realloc()
    105. }
    106. 
    107. void *av_realloc(void *ptr, size_t size)
         ^
    108. {
    109.     /* let's disallow possibly ambiguous cases */

libavutil/mem.c:110:9: Taking false branch
    108. {
    109.     /* let's disallow possibly ambiguous cases */
    110.     if (size > (INT_MAX - 16))
                 ^
    111.         return NULL;
    112. 

libavutil/mem.c:116:5: 
    114.     return _aligned_realloc(ptr, size, 32);
    115. #else
    116.     return realloc(ptr, size);
             ^
    117. #endif
    118. }

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

libavformat/icecast.c:77:15: Taking true branch
  75.         if (buf)
  76.             len += strlen(buf);
  77.         if (!(tmp = av_realloc(buf, len))) {
                    ^
  78.             av_freep(&buf);
  79.             return NULL;

libavformat/icecast.c:78:13: Skipping av_freep(): empty list of specs
  76.             len += strlen(buf);
  77.         if (!(tmp = av_realloc(buf, len))) {
  78.             av_freep(&buf);
                  ^
  79.             return NULL;
  80.         } else {

libavformat/icecast.c:79:13: 
  77.         if (!(tmp = av_realloc(buf, len))) {
  78.             av_freep(&buf);
  79.             return NULL;
                  ^
  80.         } else {
  81.             buf = tmp;

libavformat/icecast.c:89:1: return from a call to cat_header
  87.     }
  88.     return buf;
  89. }
      ^
  90. 
  91. static int icecast_close(URLContext *h)

static int icecast_open(URLContext *h, const char *uri, int flags)
{
    IcecastContext *s = h->priv_data;
    AVDictionary *opt_dict = NULL;
    char h_url[1024], host[1024], auth[1024], path[1024];
    char *headers = NULL, *user = NULL;
    int port, ret;
    if (flags & AVIO_FLAG_READ)
        return AVERROR(ENOSYS);
    headers = cat_header(headers, "Ice-Name", s->name);
    headers = cat_header(headers, "Ice-Description", s->description);
    headers = cat_header(headers, "Ice-URL", s->url);
    headers = cat_header(headers, "Ice-Genre", s->genre);
    headers = cat_header(headers, "Ice-Public", s->public ? "1" : "0");
    if (!headers) {
        ret = AVERROR(ENOMEM);
        goto cleanup;
    }
    av_dict_set(&opt_dict, "method", s->legacy_icecast ? "SOURCE" : "PUT", 0);
    av_dict_set(&opt_dict, "auth_type", "basic", 0);
    av_dict_set(&opt_dict, "headers", headers, 0);
    av_dict_set(&opt_dict, "chunked_post", "0", 0);
    av_dict_set(&opt_dict, "send_expect_100", s->legacy_icecast ? "0" : "1", 0);
    if (NOT_EMPTY(s->content_type))
        av_dict_set(&opt_dict, "content_type", s->content_type, 0);
    else
        av_dict_set(&opt_dict, "content_type", "audio/mpeg", 0);
    if (NOT_EMPTY(s->user_agent))
        av_dict_set(&opt_dict, "user_agent", s->user_agent, 0);
    av_url_split(NULL, 0, auth, sizeof(auth), host, sizeof(host),
                 &port, path, sizeof(path), uri);
    if (auth[0]) {
        char *sep = strchr(auth,':');
        if (sep) {
            *sep = 0;
            sep++;
            if (s->pass) {
                av_free(s->pass);
                av_log(h, AV_LOG_WARNING, "Overwriting -password <pass> with URI password!\n");
            }
            if (!(s->pass = av_strdup(sep))) {
                ret = AVERROR(ENOMEM);
                goto cleanup;
            }
        }
        if (!(user = av_strdup(auth))) {
            ret = AVERROR(ENOMEM);
            goto cleanup;
        }
    }
    snprintf(auth, sizeof(auth),
             "%s:%s",
             user ? user : DEFAULT_ICE_USER,
             s->pass ? s->pass : "");
    if (!path[0] || strcmp(path, "/") == 0) {
        av_log(h, AV_LOG_ERROR, "No mountpoint (path) specified!\n");
        ret = AVERROR(EIO);
        goto cleanup;
    }
    ff_url_join(h_url, sizeof(h_url), "http", auth, host, port, "%s", path);
    ret = ffurl_open(&s->hd, h_url, AVIO_FLAG_READ_WRITE, NULL, &opt_dict,
                     h->protocols, h);
cleanup:
    av_freep(&user);
    av_freep(&headers);
    av_dict_free(&opt_dict);
    return ret;
}
['static int icecast_open(URLContext *h, const char *uri, int flags)\n{\n    IcecastContext *s = h->priv_data;\n    AVDictionary *opt_dict = NULL;\n    char h_url[1024], host[1024], auth[1024], path[1024];\n    char *headers = NULL, *user = NULL;\n    int port, ret;\n    if (flags & AVIO_FLAG_READ)\n        return AVERROR(ENOSYS);\n    headers = cat_header(headers, "Ice-Name", s->name);\n    headers = cat_header(headers, "Ice-Description", s->description);\n    headers = cat_header(headers, "Ice-URL", s->url);\n    headers = cat_header(headers, "Ice-Genre", s->genre);\n    headers = cat_header(headers, "Ice-Public", s->public ? "1" : "0");\n    if (!headers) {\n        ret = AVERROR(ENOMEM);\n        goto cleanup;\n    }\n    av_dict_set(&opt_dict, "method", s->legacy_icecast ? "SOURCE" : "PUT", 0);\n    av_dict_set(&opt_dict, "auth_type", "basic", 0);\n    av_dict_set(&opt_dict, "headers", headers, 0);\n    av_dict_set(&opt_dict, "chunked_post", "0", 0);\n    av_dict_set(&opt_dict, "send_expect_100", s->legacy_icecast ? "0" : "1", 0);\n    if (NOT_EMPTY(s->content_type))\n        av_dict_set(&opt_dict, "content_type", s->content_type, 0);\n    else\n        av_dict_set(&opt_dict, "content_type", "audio/mpeg", 0);\n    if (NOT_EMPTY(s->user_agent))\n        av_dict_set(&opt_dict, "user_agent", s->user_agent, 0);\n    av_url_split(NULL, 0, auth, sizeof(auth), host, sizeof(host),\n                 &port, path, sizeof(path), uri);\n    if (auth[0]) {\n        char *sep = strchr(auth,\':\');\n        if (sep) {\n            *sep = 0;\n            sep++;\n            if (s->pass) {\n                av_free(s->pass);\n                av_log(h, AV_LOG_WARNING, "Overwriting -password <pass> with URI password!\\n");\n            }\n            if (!(s->pass = av_strdup(sep))) {\n                ret = AVERROR(ENOMEM);\n                goto cleanup;\n            }\n        }\n        if (!(user = av_strdup(auth))) {\n            ret = AVERROR(ENOMEM);\n            goto cleanup;\n        }\n    }\n    snprintf(auth, sizeof(auth),\n             "%s:%s",\n             user ? user : DEFAULT_ICE_USER,\n             s->pass ? s->pass : "");\n    if (!path[0] || strcmp(path, "/") == 0) {\n        av_log(h, AV_LOG_ERROR, "No mountpoint (path) specified!\\n");\n        ret = AVERROR(EIO);\n        goto cleanup;\n    }\n    ff_url_join(h_url, sizeof(h_url), "http", auth, host, port, "%s", path);\n    ret = ffurl_open(&s->hd, h_url, AVIO_FLAG_READ_WRITE, NULL, &opt_dict,\n                     h->protocols, h);\ncleanup:\n    av_freep(&user);\n    av_freep(&headers);\n    av_dict_free(&opt_dict);\n    return ret;\n}', 'static char *cat_header(char buf[], const char key[], const char value[])\n{\n    if (NOT_EMPTY(value)) {\n        int len = strlen(key) + strlen(value) + 5;\n        int is_first = !buf;\n        char *tmp = NULL;\n        if (buf)\n            len += strlen(buf);\n        if (!(tmp = av_realloc(buf, len))) {\n            av_freep(&buf);\n            return NULL;\n        } else {\n            buf = tmp;\n        }\n        if (is_first)\n            *buf = \'\\0\';\n        av_strlcatf(buf, len, "%s: %s\\r\\n", key, value);\n    }\n    return buf;\n}', 'void *av_realloc(void *ptr, size_t size)\n{\n    if (size > (INT_MAX - 16))\n        return NULL;\n#if HAVE_ALIGNED_MALLOC\n    return _aligned_realloc(ptr, size, 32);\n#else\n    return realloc(ptr, size);\n#endif\n}', 'size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...)\n{\n    int len = strlen(dst);\n    va_list vl;\n    va_start(vl, fmt);\n    len += vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl);\n    va_end(vl);\n    return len;\n}']