ffserver.c:3365: error: Memory Leak
  `stream` is not reachable after line 3365, column 14.

ffserver.c:3355:1: start of procedure build_file_streams()
3353. 
3354. /* compute the needed AVStream for each file */
3355. static void build_file_streams(void)
      ^
3356. {
3357.     FFStream *stream, *stream_next;

ffserver.c:3362:9: 
3360. 
3361.     /* gather all streams */
3362.     for(stream = first_stream; stream != NULL; stream = stream_next) {
              ^
3363.         stream_next = stream->next;
3364.         if (stream->stream_type == STREAM_TYPE_LIVE &&

ffserver.c:3362:32: Loop condition is true. Entering loop body
3360. 
3361.     /* gather all streams */
3362.     for(stream = first_stream; stream != NULL; stream = stream_next) {
                                     ^
3363.         stream_next = stream->next;
3364.         if (stream->stream_type == STREAM_TYPE_LIVE &&

ffserver.c:3363:9: 
3361.     /* gather all streams */
3362.     for(stream = first_stream; stream != NULL; stream = stream_next) {
3363.         stream_next = stream->next;
              ^
3364.         if (stream->stream_type == STREAM_TYPE_LIVE &&
3365.             !stream->feed) {

ffserver.c:3364:13: Taking true branch
3362.     for(stream = first_stream; stream != NULL; stream = stream_next) {
3363.         stream_next = stream->next;
3364.         if (stream->stream_type == STREAM_TYPE_LIVE &&
                  ^
3365.             !stream->feed) {
3366.             /* the stream comes from a file */

ffserver.c:3365:14: Taking true branch
3363.         stream_next = stream->next;
3364.         if (stream->stream_type == STREAM_TYPE_LIVE &&
3365.             !stream->feed) {
                   ^
3366.             /* the stream comes from a file */
3367.             /* try to open the file */

ffserver.c:3369:13: 
3367.             /* try to open the file */
3368.             /* open stream */
3369.             stream->ap_in = av_mallocz(sizeof(AVFormatParameters));
                  ^
3370.             if (stream->fmt && !strcmp(stream->fmt->name, "rtp")) {
3371.                 /* specific case : if transport stream output to RTP,

libavutil/mem.c:132:1: start of procedure av_mallocz()
  130. }
  131. 
  132. void *av_mallocz(unsigned int size)
       ^
  133. {
  134.     void *ptr = av_malloc(size);

libavutil/mem.c:134:5: 
  132. void *av_mallocz(unsigned int size)
  133. {
  134.     void *ptr = av_malloc(size);
           ^
  135.     if (ptr)
  136.         memset(ptr, 0, size);

libavutil/mem.c:42:1: start of procedure av_malloc()
    40.    linker will do it automatically */
    41. 
    42. void *av_malloc(unsigned int size)
        ^
    43. {
    44.     void *ptr;

libavutil/mem.c:50:8: Taking false branch
    48. 
    49.     /* let's disallow possible ambiguous cases */
    50.     if(size > (INT_MAX-16) )
               ^
    51.         return NULL;
    52. 

libavutil/mem.c:61:5: Skipping memalign(): method has no implementation
    59.     ((char*)ptr)[-1]= diff;
    60. #elif defined (HAVE_MEMALIGN)
    61.     ptr = memalign(16,size);
            ^
    62.     /* Why 64?
    63.        Indeed, we should align it:

libavutil/mem.c:91:5: 
    89.     ptr = malloc(size);
    90. #endif
    91.     return ptr;
            ^
    92. }
    93. 

libavutil/mem.c:92:1: return from a call to av_malloc
    90. #endif
    91.     return ptr;
    92. }
        ^
    93. 
    94. void *av_realloc(void *ptr, unsigned int size)

libavutil/mem.c:135:9: Taking false branch
  133. {
  134.     void *ptr = av_malloc(size);
  135.     if (ptr)
               ^
  136.         memset(ptr, 0, size);
  137.     return ptr;

libavutil/mem.c:137:5: 
  135.     if (ptr)
  136.         memset(ptr, 0, size);
  137.     return ptr;
           ^
  138. }
  139. 

libavutil/mem.c:138:1: return from a call to av_mallocz
  136.         memset(ptr, 0, size);
  137.     return ptr;
  138. }
       ^
  139. 
  140. char *av_strdup(const char *s)

ffserver.c:3370:17: Taking true branch
3368.             /* open stream */
3369.             stream->ap_in = av_mallocz(sizeof(AVFormatParameters));
3370.             if (stream->fmt && !strcmp(stream->fmt->name, "rtp")) {
                      ^
3371.                 /* specific case : if transport stream output to RTP,
3372.                    we use a raw transport stream reader */

ffserver.c:3370:33: Taking false branch
3368.             /* open stream */
3369.             stream->ap_in = av_mallocz(sizeof(AVFormatParameters));
3370.             if (stream->fmt && !strcmp(stream->fmt->name, "rtp")) {
                                      ^
3371.                 /* specific case : if transport stream output to RTP,
3372.                    we use a raw transport stream reader */

ffserver.c:3377:17: 
3375.             }
3376. 
3377.             if ((ret = av_open_input_file(&infile, stream->feed_filename,
                      ^
3378.                                           stream->ifmt, 0, stream->ap_in)) < 0) {
3379.                 http_log("could not open %s: %d\n", stream->feed_filename, ret);

libavformat/utils.c:511:1: start of procedure av_open_input_file()
  509. #define PROBE_BUF_MAX (1<<20)
  510. 
  511. int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
       ^
  512.                        AVInputFormat *fmt,
  513.                        int buf_size,

libavformat/utils.c:517:5: 
  515. {
  516.     int err, probe_size;
  517.     AVProbeData probe_data, *pd = &probe_data;
           ^
  518.     ByteIOContext *pb = NULL;
  519. 

libavformat/utils.c:518:5: 
  516.     int err, probe_size;
  517.     AVProbeData probe_data, *pd = &probe_data;
  518.     ByteIOContext *pb = NULL;
           ^
  519. 
  520.     pd->filename = "";

libavformat/utils.c:520:5: 
  518.     ByteIOContext *pb = NULL;
  519. 
  520.     pd->filename = "";
           ^
  521.     if (filename)
  522.         pd->filename = filename;

libavformat/utils.c:521:9: Taking true branch
  519. 
  520.     pd->filename = "";
  521.     if (filename)
               ^
  522.         pd->filename = filename;
  523.     pd->buf = NULL;

libavformat/utils.c:522:9: 
  520.     pd->filename = "";
  521.     if (filename)
  522.         pd->filename = filename;
               ^
  523.     pd->buf = NULL;
  524.     pd->buf_size = 0;

libavformat/utils.c:523:5: 
  521.     if (filename)
  522.         pd->filename = filename;
  523.     pd->buf = NULL;
           ^
  524.     pd->buf_size = 0;
  525. 

libavformat/utils.c:524:5: 
  522.         pd->filename = filename;
  523.     pd->buf = NULL;
  524.     pd->buf_size = 0;
           ^
  525. 
  526.     if (!fmt) {

libavformat/utils.c:526:10: Taking false branch
  524.     pd->buf_size = 0;
  525. 
  526.     if (!fmt) {
                ^
  527.         /* guess format if no file can be opened */
  528.         fmt = av_probe_input_format(pd, 0);

libavformat/utils.c:533:10: Taking false branch
  531.     /* Do not open file if the format does not need it. XXX: specific
  532.        hack needed to handle RTSP/TCP */
  533.     if (!fmt || !(fmt->flags & AVFMT_NOFILE)) {
                ^
  534.         /* if no file needed do not try to open one */
  535.         if ((err=url_fopen(&pb, filename, URL_RDONLY)) < 0) {

libavformat/utils.c:533:19: Taking true branch
  531.     /* Do not open file if the format does not need it. XXX: specific
  532.        hack needed to handle RTSP/TCP */
  533.     if (!fmt || !(fmt->flags & AVFMT_NOFILE)) {
                         ^
  534.         /* if no file needed do not try to open one */
  535.         if ((err=url_fopen(&pb, filename, URL_RDONLY)) < 0) {

libavformat/utils.c:535:13: 
  533.     if (!fmt || !(fmt->flags & AVFMT_NOFILE)) {
  534.         /* if no file needed do not try to open one */
  535.         if ((err=url_fopen(&pb, filename, URL_RDONLY)) < 0) {
                   ^
  536.             goto fail;
  537.         }

libavformat/aviobuf.c:585:1: start of procedure url_fopen()
    583. }
    584. 
    585. int url_fopen(ByteIOContext **s, const char *filename, int flags)
         ^
    586. {
    587.     URLContext *h;

libavformat/aviobuf.c:590:5: Skipping url_open(): empty list of specs
    588.     int err;
    589. 
    590.     err = url_open(&h, filename, flags);
             ^
    591.     if (err < 0)
    592.         return err;

libavformat/aviobuf.c:591:9: Taking true branch
    589. 
    590.     err = url_open(&h, filename, flags);
    591.     if (err < 0)
                 ^
    592.         return err;
    593.     err = url_fdopen(s, h);

libavformat/aviobuf.c:592:9: 
    590.     err = url_open(&h, filename, flags);
    591.     if (err < 0)
    592.         return err;
                 ^
    593.     err = url_fdopen(s, h);
    594.     if (err < 0) {

libavformat/aviobuf.c:599:1: return from a call to url_fopen
    597.     }
    598.     return 0;
    599. }
         ^
    600. 
    601. int url_fclose(ByteIOContext *s)

libavformat/utils.c:535:13: Taking true branch
  533.     if (!fmt || !(fmt->flags & AVFMT_NOFILE)) {
  534.         /* if no file needed do not try to open one */
  535.         if ((err=url_fopen(&pb, filename, URL_RDONLY)) < 0) {
                   ^
  536.             goto fail;
  537.         }

libavformat/utils.c:579:2: 
  577.         goto fail;
  578.     return 0;
  579.  fail:
        ^
  580.     av_freep(&pd->buf);
  581.     if (pb)

libavformat/utils.c:580:5: 
  578.     return 0;
  579.  fail:
  580.     av_freep(&pd->buf);
           ^
  581.     if (pb)
  582.         url_fclose(pb);

libavutil/mem.c:125:1: start of procedure av_freep()
    123. }
    124. 
    125. void av_freep(void *arg)
         ^
    126. {
    127.     void **ptr= (void**)arg;

libavutil/mem.c:127:5: 
    125. void av_freep(void *arg)
    126. {
    127.     void **ptr= (void**)arg;
             ^
    128.     av_free(*ptr);
    129.     *ptr = NULL;

libavutil/mem.c:128:5: 
    126. {
    127.     void **ptr= (void**)arg;
    128.     av_free(*ptr);
             ^
    129.     *ptr = NULL;
    130. }

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

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

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

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

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

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

libavformat/utils.c:581:9: Taking false branch
  579.  fail:
  580.     av_freep(&pd->buf);
  581.     if (pb)
               ^
  582.         url_fclose(pb);
  583.     *ic_ptr = NULL;

libavformat/utils.c:583:5: 
  581.     if (pb)
  582.         url_fclose(pb);
  583.     *ic_ptr = NULL;
           ^
  584.     return err;
  585. 

libavformat/utils.c:584:5: 
  582.         url_fclose(pb);
  583.     *ic_ptr = NULL;
  584.     return err;
           ^
  585. 
  586. }

libavformat/utils.c:586:1: return from a call to av_open_input_file
  584.     return err;
  585. 
  586. }
       ^
  587. 
  588. /*******************************************************/

ffserver.c:3377:17: Taking true branch
3375.             }
3376. 
3377.             if ((ret = av_open_input_file(&infile, stream->feed_filename,
                      ^
3378.                                           stream->ifmt, 0, stream->ap_in)) < 0) {
3379.                 http_log("could not open %s: %d\n", stream->feed_filename, ret);

ffserver.c:3379:17: 
3377.             if ((ret = av_open_input_file(&infile, stream->feed_filename,
3378.                                           stream->ifmt, 0, stream->ap_in)) < 0) {
3379.                 http_log("could not open %s: %d\n", stream->feed_filename, ret);
                      ^
3380.                 /* remove stream (no need to spend more time on it) */
3381.             fail:

ffserver.c:338:1: start of procedure http_log()
  336. }
  337. 
  338. void __attribute__ ((format (printf, 1, 2))) http_log(const char *fmt, ...)
       ^
  339. {
  340.     va_list vargs;

ffserver.c:341:5: 
  339. {
  340.     va_list vargs;
  341.     va_start(vargs, fmt);
           ^
  342.     http_vlog(fmt, vargs);
  343.     va_end(vargs);

ffserver.c:342:5: 
  340.     va_list vargs;
  341.     va_start(vargs, fmt);
  342.     http_vlog(fmt, vargs);
           ^
  343.     va_end(vargs);
  344. }

ffserver.c:323:1: start of procedure http_vlog()
    321. }
    322. 
    323. static void http_vlog(const char *fmt, va_list vargs)
         ^
    324. {
    325.     static int print_prefix = 1;

ffserver.c:325:5: 
    323. static void http_vlog(const char *fmt, va_list vargs)
    324. {
    325.     static int print_prefix = 1;
             ^
    326.     if (logfile) {
    327.         if (print_prefix) {

ffserver.c:326:9: Taking true branch
    324. {
    325.     static int print_prefix = 1;
    326.     if (logfile) {
                 ^
    327.         if (print_prefix) {
    328.             char buf[32];

ffserver.c:327:13: Taking true branch
    325.     static int print_prefix = 1;
    326.     if (logfile) {
    327.         if (print_prefix) {
                     ^
    328.             char buf[32];
    329.             ctime1(buf);

ffserver.c:329:13: Skipping ctime1(): empty list of specs
    327.         if (print_prefix) {
    328.             char buf[32];
    329.             ctime1(buf);
                     ^
    330.             fprintf(logfile, "%s ", buf);
    331.         }

ffserver.c:330:13: 
    328.             char buf[32];
    329.             ctime1(buf);
    330.             fprintf(logfile, "%s ", buf);
                     ^
    331.         }
    332.         print_prefix = strstr(fmt, "\n") != NULL;

ffserver.c:332:24: Condition is true
    330.             fprintf(logfile, "%s ", buf);
    331.         }
    332.         print_prefix = strstr(fmt, "\n") != NULL;
                                ^
    333.         vfprintf(logfile, fmt, vargs);
    334.         fflush(logfile);

ffserver.c:332:9: 
    330.             fprintf(logfile, "%s ", buf);
    331.         }
    332.         print_prefix = strstr(fmt, "\n") != NULL;
                 ^
    333.         vfprintf(logfile, fmt, vargs);
    334.         fflush(logfile);

ffserver.c:333:9: 
    331.         }
    332.         print_prefix = strstr(fmt, "\n") != NULL;
    333.         vfprintf(logfile, fmt, vargs);
                 ^
    334.         fflush(logfile);
    335.     }

ffserver.c:334:9: 
    332.         print_prefix = strstr(fmt, "\n") != NULL;
    333.         vfprintf(logfile, fmt, vargs);
    334.         fflush(logfile);
                 ^
    335.     }
    336. }

ffserver.c:326:5: 
    324. {
    325.     static int print_prefix = 1;
    326.     if (logfile) {
             ^
    327.         if (print_prefix) {
    328.             char buf[32];

ffserver.c:336:1: return from a call to http_vlog
    334.         fflush(logfile);
    335.     }
    336. }
         ^
    337. 
    338. void __attribute__ ((format (printf, 1, 2))) http_log(const char *fmt, ...)

ffserver.c:343:5: 
  341.     va_start(vargs, fmt);
  342.     http_vlog(fmt, vargs);
  343.     va_end(vargs);
           ^
  344. }
  345. 

ffserver.c:344:1: return from a call to http_log
  342.     http_vlog(fmt, vargs);
  343.     va_end(vargs);
  344. }
       ^
  345. 
  346. static void http_av_log(void *ptr, int level, const char *fmt, va_list vargs)

ffserver.c:3381:13: 
3379.                 http_log("could not open %s: %d\n", stream->feed_filename, ret);
3380.                 /* remove stream (no need to spend more time on it) */
3381.             fail:
                  ^
3382.                 remove_stream(stream);
3383.             } else {

ffserver.c:3382:17: Skipping remove_stream(): empty list of specs
3380.                 /* remove stream (no need to spend more time on it) */
3381.             fail:
3382.                 remove_stream(stream);
                      ^
3383.             } else {
3384.                 /* find all the AVStreams inside and reference them in

ffserver.c:3362:48: 
3360. 
3361.     /* gather all streams */
3362.     for(stream = first_stream; stream != NULL; stream = stream_next) {
                                                     ^
3363.         stream_next = stream->next;
3364.         if (stream->stream_type == STREAM_TYPE_LIVE &&

ffserver.c:3362:32: Loop condition is true. Entering loop body
3360. 
3361.     /* gather all streams */
3362.     for(stream = first_stream; stream != NULL; stream = stream_next) {
                                     ^
3363.         stream_next = stream->next;
3364.         if (stream->stream_type == STREAM_TYPE_LIVE &&

ffserver.c:3363:9: 
3361.     /* gather all streams */
3362.     for(stream = first_stream; stream != NULL; stream = stream_next) {
3363.         stream_next = stream->next;
              ^
3364.         if (stream->stream_type == STREAM_TYPE_LIVE &&
3365.             !stream->feed) {

ffserver.c:3364:13: Taking true branch
3362.     for(stream = first_stream; stream != NULL; stream = stream_next) {
3363.         stream_next = stream->next;
3364.         if (stream->stream_type == STREAM_TYPE_LIVE &&
                  ^
3365.             !stream->feed) {
3366.             /* the stream comes from a file */

ffserver.c:3365:14: Taking false branch
3363.         stream_next = stream->next;
3364.         if (stream->stream_type == STREAM_TYPE_LIVE &&
3365.             !stream->feed) {
                   ^
3366.             /* the stream comes from a file */
3367.             /* try to open the file */

static void build_file_streams(void)
{
    FFStream *stream, *stream_next;
    AVFormatContext *infile;
    int i, ret;
    for(stream = first_stream; stream != NULL; stream = stream_next) {
        stream_next = stream->next;
        if (stream->stream_type == STREAM_TYPE_LIVE &&
            !stream->feed) {
            stream->ap_in = av_mallocz(sizeof(AVFormatParameters));
            if (stream->fmt && !strcmp(stream->fmt->name, "rtp")) {
                stream->ap_in->mpeg2ts_raw = 1;
                stream->ap_in->mpeg2ts_compute_pcr = 1;
            }
            if ((ret = av_open_input_file(&infile, stream->feed_filename,
                                          stream->ifmt, 0, stream->ap_in)) < 0) {
                http_log("could not open %s: %d\n", stream->feed_filename, ret);
            fail:
                remove_stream(stream);
            } else {
                if (av_find_stream_info(infile) < 0) {
                    http_log("Could not find codec parameters from '%s'\n",
                             stream->feed_filename);
                    av_close_input_file(infile);
                    goto fail;
                }
                extract_mpeg4_header(infile);
                for(i=0;i<infile->nb_streams;i++)
                    add_av_stream1(stream, infile->streams[i]->codec);
                av_close_input_file(infile);
            }
        }
    }
}
['static void build_file_streams(void)\n{\n    FFStream *stream, *stream_next;\n    AVFormatContext *infile;\n    int i, ret;\n    for(stream = first_stream; stream != NULL; stream = stream_next) {\n        stream_next = stream->next;\n        if (stream->stream_type == STREAM_TYPE_LIVE &&\n            !stream->feed) {\n            stream->ap_in = av_mallocz(sizeof(AVFormatParameters));\n            if (stream->fmt && !strcmp(stream->fmt->name, "rtp")) {\n                stream->ap_in->mpeg2ts_raw = 1;\n                stream->ap_in->mpeg2ts_compute_pcr = 1;\n            }\n            if ((ret = av_open_input_file(&infile, stream->feed_filename,\n                                          stream->ifmt, 0, stream->ap_in)) < 0) {\n                http_log("could not open %s: %d\\n", stream->feed_filename, ret);\n            fail:\n                remove_stream(stream);\n            } else {\n                if (av_find_stream_info(infile) < 0) {\n                    http_log("Could not find codec parameters from \'%s\'\\n",\n                             stream->feed_filename);\n                    av_close_input_file(infile);\n                    goto fail;\n                }\n                extract_mpeg4_header(infile);\n                for(i=0;i<infile->nb_streams;i++)\n                    add_av_stream1(stream, infile->streams[i]->codec);\n                av_close_input_file(infile);\n            }\n        }\n    }\n}', 'void *av_mallocz(unsigned int size)\n{\n    void *ptr = av_malloc(size);\n    if (ptr)\n        memset(ptr, 0, size);\n    return ptr;\n}', 'void *av_malloc(unsigned int size)\n{\n    void *ptr;\n#ifdef CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#ifdef CONFIG_MEMALIGN_HACK\n    ptr = malloc(size+16);\n    if(!ptr)\n        return ptr;\n    diff= ((-(long)ptr - 1)&15) + 1;\n    ptr = (char*)ptr + diff;\n    ((char*)ptr)[-1]= diff;\n#elif defined (HAVE_MEMALIGN)\n    ptr = memalign(16,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}', 'int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,\n                       AVInputFormat *fmt,\n                       int buf_size,\n                       AVFormatParameters *ap)\n{\n    int err, probe_size;\n    AVProbeData probe_data, *pd = &probe_data;\n    ByteIOContext *pb = NULL;\n    pd->filename = "";\n    if (filename)\n        pd->filename = filename;\n    pd->buf = NULL;\n    pd->buf_size = 0;\n    if (!fmt) {\n        fmt = av_probe_input_format(pd, 0);\n    }\n    if (!fmt || !(fmt->flags & AVFMT_NOFILE)) {\n        if ((err=url_fopen(&pb, filename, URL_RDONLY)) < 0) {\n            goto fail;\n        }\n        if (buf_size > 0) {\n            url_setbufsize(pb, buf_size);\n        }\n        for(probe_size= PROBE_BUF_MIN; probe_size<=PROBE_BUF_MAX && !fmt; probe_size<<=1){\n            int score= probe_size < PROBE_BUF_MAX ? AVPROBE_SCORE_MAX/4 : 0;\n            pd->buf= av_realloc(pd->buf, probe_size + AVPROBE_PADDING_SIZE);\n            pd->buf_size = get_buffer(pb, pd->buf, probe_size);\n            memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE);\n            if (url_fseek(pb, 0, SEEK_SET) < 0) {\n                url_fclose(pb);\n                if (url_fopen(&pb, filename, URL_RDONLY) < 0) {\n                    pb = NULL;\n                    err = AVERROR(EIO);\n                    goto fail;\n                }\n            }\n            fmt = av_probe_input_format2(pd, 1, &score);\n        }\n        av_freep(&pd->buf);\n    }\n    if (!fmt) {\n        err = AVERROR_NOFMT;\n        goto fail;\n    }\n    if (fmt->flags & AVFMT_NEEDNUMBER) {\n        if (!av_filename_number_test(filename)) {\n            err = AVERROR_NUMEXPECTED;\n            goto fail;\n        }\n    }\n    err = av_open_input_stream(ic_ptr, pb, filename, fmt, ap);\n    if (err)\n        goto fail;\n    return 0;\n fail:\n    av_freep(&pd->buf);\n    if (pb)\n        url_fclose(pb);\n    *ic_ptr = NULL;\n    return err;\n}', 'int url_fopen(ByteIOContext **s, const char *filename, int flags)\n{\n    URLContext *h;\n    int err;\n    err = url_open(&h, filename, flags);\n    if (err < 0)\n        return err;\n    err = url_fdopen(s, h);\n    if (err < 0) {\n        url_close(h);\n        return err;\n    }\n    return 0;\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}', 'void __attribute__ ((format (printf, 1, 2))) http_log(const char *fmt, ...)\n{\n    va_list vargs;\n    va_start(vargs, fmt);\n    http_vlog(fmt, vargs);\n    va_end(vargs);\n}', 'static void http_vlog(const char *fmt, va_list vargs)\n{\n    static int print_prefix = 1;\n    if (logfile) {\n        if (print_prefix) {\n            char buf[32];\n            ctime1(buf);\n            fprintf(logfile, "%s ", buf);\n        }\n        print_prefix = strstr(fmt, "\\n") != NULL;\n        vfprintf(logfile, fmt, vargs);\n        fflush(logfile);\n    }\n}']