libavformat/hls.c:495: error: Memory Leak
  memory dynamically allocated to `buf` by call to `av_opt_get()` at line 485, column 13 is not reachable after line 495, column 1.

libavformat/hls.c:477:1: start of procedure save_avio_options()
475. }
476. 
477. static int save_avio_options(AVFormatContext *s)
     ^
478. {
479.     HLSContext *c = s->priv_data;

libavformat/hls.c:479:5: 
477. static int save_avio_options(AVFormatContext *s)
478. {
479.     HLSContext *c = s->priv_data;
         ^
480.     const char *opts[] = { "headers", "user_agent", NULL }, **opt = opts;
481.     uint8_t *buf;

libavformat/hls.c:480:5: 
478. {
479.     HLSContext *c = s->priv_data;
480.     const char *opts[] = { "headers", "user_agent", NULL }, **opt = opts;
         ^
481.     uint8_t *buf;
482.     int ret = 0;

libavformat/hls.c:482:5: 
480.     const char *opts[] = { "headers", "user_agent", NULL }, **opt = opts;
481.     uint8_t *buf;
482.     int ret = 0;
         ^
483. 
484.     while (*opt) {

libavformat/hls.c:484:12: Loop condition is true. Entering loop body
482.     int ret = 0;
483. 
484.     while (*opt) {
                ^
485.         if (av_opt_get(s->pb, *opt, AV_OPT_SEARCH_CHILDREN, &buf) >= 0) {
486.             ret = av_dict_set(&c->avio_opts, *opt, buf,

libavformat/hls.c:485:13: 
483. 
484.     while (*opt) {
485.         if (av_opt_get(s->pb, *opt, AV_OPT_SEARCH_CHILDREN, &buf) >= 0) {
                 ^
486.             ret = av_dict_set(&c->avio_opts, *opt, buf,
487.                               AV_DICT_DONT_STRDUP_VAL);

libavutil/opt.c:330:1: start of procedure av_opt_get()
  328. }
  329. 
  330. int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
       ^
  331. {
  332.     void *dst, *target_obj;

libavutil/opt.c:333:5: Skipping av_opt_find2(): empty list of specs
  331. {
  332.     void *dst, *target_obj;
  333.     const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
           ^
  334.     uint8_t *bin, buf[128];
  335.     int len, i, ret;

libavutil/opt.c:337:10: Taking false branch
  335.     int len, i, ret;
  336. 
  337.     if (!o || !target_obj)
                ^
  338.         return AVERROR_OPTION_NOT_FOUND;
  339. 

libavutil/opt.c:337:16: Taking false branch
  335.     int len, i, ret;
  336. 
  337.     if (!o || !target_obj)
                      ^
  338.         return AVERROR_OPTION_NOT_FOUND;
  339. 

libavutil/opt.c:340:5: 
  338.         return AVERROR_OPTION_NOT_FOUND;
  339. 
  340.     dst = (uint8_t*)target_obj + o->offset;
           ^
  341. 
  342.     buf[0] = 0;

libavutil/opt.c:342:5: 
  340.     dst = (uint8_t*)target_obj + o->offset;
  341. 
  342.     buf[0] = 0;
           ^
  343.     switch (o->type) {
  344.     case AV_OPT_TYPE_FLAGS:     ret = snprintf(buf, sizeof(buf), "0x%08X",  *(int    *)dst);break;

libavutil/opt.c:343:5: 
  341. 
  342.     buf[0] = 0;
  343.     switch (o->type) {
           ^
  344.     case AV_OPT_TYPE_FLAGS:     ret = snprintf(buf, sizeof(buf), "0x%08X",  *(int    *)dst);break;
  345.     case AV_OPT_TYPE_INT:       ret = snprintf(buf, sizeof(buf), "%d" ,     *(int    *)dst);break;

libavutil/opt.c:344:5: Switch condition is false. Skipping switch case
  342.     buf[0] = 0;
  343.     switch (o->type) {
  344.     case AV_OPT_TYPE_FLAGS:     ret = snprintf(buf, sizeof(buf), "0x%08X",  *(int    *)dst);break;
           ^
  345.     case AV_OPT_TYPE_INT:       ret = snprintf(buf, sizeof(buf), "%d" ,     *(int    *)dst);break;
  346.     case AV_OPT_TYPE_INT64:     ret = snprintf(buf, sizeof(buf), "%"PRId64, *(int64_t*)dst);break;

libavutil/opt.c:345:5: Switch condition is false. Skipping switch case
  343.     switch (o->type) {
  344.     case AV_OPT_TYPE_FLAGS:     ret = snprintf(buf, sizeof(buf), "0x%08X",  *(int    *)dst);break;
  345.     case AV_OPT_TYPE_INT:       ret = snprintf(buf, sizeof(buf), "%d" ,     *(int    *)dst);break;
           ^
  346.     case AV_OPT_TYPE_INT64:     ret = snprintf(buf, sizeof(buf), "%"PRId64, *(int64_t*)dst);break;
  347.     case AV_OPT_TYPE_FLOAT:     ret = snprintf(buf, sizeof(buf), "%f" ,     *(float  *)dst);break;

libavutil/opt.c:346:5: Switch condition is false. Skipping switch case
  344.     case AV_OPT_TYPE_FLAGS:     ret = snprintf(buf, sizeof(buf), "0x%08X",  *(int    *)dst);break;
  345.     case AV_OPT_TYPE_INT:       ret = snprintf(buf, sizeof(buf), "%d" ,     *(int    *)dst);break;
  346.     case AV_OPT_TYPE_INT64:     ret = snprintf(buf, sizeof(buf), "%"PRId64, *(int64_t*)dst);break;
           ^
  347.     case AV_OPT_TYPE_FLOAT:     ret = snprintf(buf, sizeof(buf), "%f" ,     *(float  *)dst);break;
  348.     case AV_OPT_TYPE_DOUBLE:    ret = snprintf(buf, sizeof(buf), "%f" ,     *(double *)dst);break;

libavutil/opt.c:347:5: Switch condition is false. Skipping switch case
  345.     case AV_OPT_TYPE_INT:       ret = snprintf(buf, sizeof(buf), "%d" ,     *(int    *)dst);break;
  346.     case AV_OPT_TYPE_INT64:     ret = snprintf(buf, sizeof(buf), "%"PRId64, *(int64_t*)dst);break;
  347.     case AV_OPT_TYPE_FLOAT:     ret = snprintf(buf, sizeof(buf), "%f" ,     *(float  *)dst);break;
           ^
  348.     case AV_OPT_TYPE_DOUBLE:    ret = snprintf(buf, sizeof(buf), "%f" ,     *(double *)dst);break;
  349.     case AV_OPT_TYPE_RATIONAL:  ret = snprintf(buf, sizeof(buf), "%d/%d",   ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;

libavutil/opt.c:348:5: Switch condition is false. Skipping switch case
  346.     case AV_OPT_TYPE_INT64:     ret = snprintf(buf, sizeof(buf), "%"PRId64, *(int64_t*)dst);break;
  347.     case AV_OPT_TYPE_FLOAT:     ret = snprintf(buf, sizeof(buf), "%f" ,     *(float  *)dst);break;
  348.     case AV_OPT_TYPE_DOUBLE:    ret = snprintf(buf, sizeof(buf), "%f" ,     *(double *)dst);break;
           ^
  349.     case AV_OPT_TYPE_RATIONAL:  ret = snprintf(buf, sizeof(buf), "%d/%d",   ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
  350.     case AV_OPT_TYPE_STRING:

libavutil/opt.c:349:5: Switch condition is false. Skipping switch case
  347.     case AV_OPT_TYPE_FLOAT:     ret = snprintf(buf, sizeof(buf), "%f" ,     *(float  *)dst);break;
  348.     case AV_OPT_TYPE_DOUBLE:    ret = snprintf(buf, sizeof(buf), "%f" ,     *(double *)dst);break;
  349.     case AV_OPT_TYPE_RATIONAL:  ret = snprintf(buf, sizeof(buf), "%d/%d",   ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
           ^
  350.     case AV_OPT_TYPE_STRING:
  351.         if (*(uint8_t**)dst)

libavutil/opt.c:350:5: Switch condition is true. Entering switch case
  348.     case AV_OPT_TYPE_DOUBLE:    ret = snprintf(buf, sizeof(buf), "%f" ,     *(double *)dst);break;
  349.     case AV_OPT_TYPE_RATIONAL:  ret = snprintf(buf, sizeof(buf), "%d/%d",   ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
  350.     case AV_OPT_TYPE_STRING:
           ^
  351.         if (*(uint8_t**)dst)
  352.             *out_val = av_strdup(*(uint8_t**)dst);

libavutil/opt.c:351:13: Taking false branch
  349.     case AV_OPT_TYPE_RATIONAL:  ret = snprintf(buf, sizeof(buf), "%d/%d",   ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
  350.     case AV_OPT_TYPE_STRING:
  351.         if (*(uint8_t**)dst)
                   ^
  352.             *out_val = av_strdup(*(uint8_t**)dst);
  353.         else

libavutil/opt.c:354:13: 
  352.             *out_val = av_strdup(*(uint8_t**)dst);
  353.         else
  354.             *out_val = av_strdup("");
                   ^
  355.         return *out_val ? 0 : AVERROR(ENOMEM);
  356.     case AV_OPT_TYPE_BINARY:

libavutil/mem.c:219:1: start of procedure av_strdup()
    217. }
    218. 
    219. char *av_strdup(const char *s)
         ^
    220. {
    221.     char *ptr = NULL;

libavutil/mem.c:221:5: 
    219. char *av_strdup(const char *s)
    220. {
    221.     char *ptr = NULL;
             ^
    222.     if (s) {
    223.         int len = strlen(s) + 1;

libavutil/mem.c:222:9: Taking true branch
    220. {
    221.     char *ptr = NULL;
    222.     if (s) {
                 ^
    223.         int len = strlen(s) + 1;
    224.         ptr = av_realloc(NULL, len);

libavutil/mem.c:223:9: 
    221.     char *ptr = NULL;
    222.     if (s) {
    223.         int len = strlen(s) + 1;
                 ^
    224.         ptr = av_realloc(NULL, len);
    225.         if (ptr)

libavutil/mem.c:224:9: 
    222.     if (s) {
    223.         int len = strlen(s) + 1;
    224.         ptr = av_realloc(NULL, len);
                 ^
    225.         if (ptr)
    226.             memcpy(ptr, s, len);

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/mem.c:225:13: Taking true branch
    223.         int len = strlen(s) + 1;
    224.         ptr = av_realloc(NULL, len);
    225.         if (ptr)
                     ^
    226.             memcpy(ptr, s, len);
    227.     }

libavutil/mem.c:226:13: 
    224.         ptr = av_realloc(NULL, len);
    225.         if (ptr)
    226.             memcpy(ptr, s, len);
                     ^
    227.     }
    228.     return ptr;

libavutil/mem.c:228:5: 
    226.             memcpy(ptr, s, len);
    227.     }
    228.     return ptr;
             ^
    229. }
    230. 

libavutil/mem.c:229:1: return from a call to av_strdup
    227.     }
    228.     return ptr;
    229. }
         ^
    230. 
    231. char *av_strndup(const char *s, size_t len)

libavutil/opt.c:355:16: Condition is true
  353.         else
  354.             *out_val = av_strdup("");
  355.         return *out_val ? 0 : AVERROR(ENOMEM);
                      ^
  356.     case AV_OPT_TYPE_BINARY:
  357.         len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *));

libavutil/opt.c:355:9: 
  353.         else
  354.             *out_val = av_strdup("");
  355.         return *out_val ? 0 : AVERROR(ENOMEM);
               ^
  356.     case AV_OPT_TYPE_BINARY:
  357.         len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *));

libavutil/opt.c:374:1: return from a call to av_opt_get
  372.     *out_val = av_strdup(buf);
  373.     return *out_val ? 0 : AVERROR(ENOMEM);
  374. }
       ^
  375. 
  376. static int get_number(void *obj, const char *name, double *num, int *den, int64_t *intnum,

libavformat/hls.c:485:13: Taking true branch
483. 
484.     while (*opt) {
485.         if (av_opt_get(s->pb, *opt, AV_OPT_SEARCH_CHILDREN, &buf) >= 0) {
                 ^
486.             ret = av_dict_set(&c->avio_opts, *opt, buf,
487.                               AV_DICT_DONT_STRDUP_VAL);

libavformat/hls.c:486:13: 
484.     while (*opt) {
485.         if (av_opt_get(s->pb, *opt, AV_OPT_SEARCH_CHILDREN, &buf) >= 0) {
486.             ret = av_dict_set(&c->avio_opts, *opt, buf,
                 ^
487.                               AV_DICT_DONT_STRDUP_VAL);
488.             if (ret < 0)

libavutil/dict.c:68:1: start of procedure av_dict_set()
  66. }
  67. 
  68. int av_dict_set(AVDictionary **pm, const char *key, const char *value,
      ^
  69.                 int flags)
  70. {

libavutil/dict.c:71:5: 
  69.                 int flags)
  70. {
  71.     AVDictionary *m = *pm;
          ^
  72.     AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
  73.     char *oldval = NULL;

libavutil/dict.c:72:5: Skipping av_dict_get(): empty list of specs
  70. {
  71.     AVDictionary *m = *pm;
  72.     AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
          ^
  73.     char *oldval = NULL;
  74.     int allocated = !!m;

libavutil/dict.c:73:5: 
  71.     AVDictionary *m = *pm;
  72.     AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
  73.     char *oldval = NULL;
          ^
  74.     int allocated = !!m;
  75. 

libavutil/dict.c:74:23: Condition is false
  72.     AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
  73.     char *oldval = NULL;
  74.     int allocated = !!m;
                            ^
  75. 
  76.     if (!m)

libavutil/dict.c:74:21: 
  72.     AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
  73.     char *oldval = NULL;
  74.     int allocated = !!m;
                          ^
  75. 
  76.     if (!m)

libavutil/dict.c:74:5: 
  72.     AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
  73.     char *oldval = NULL;
  74.     int allocated = !!m;
          ^
  75. 
  76.     if (!m)

libavutil/dict.c:76:10: Taking false branch
  74.     int allocated = !!m;
  75. 
  76.     if (!m)
               ^
  77.         m = *pm = av_mallocz(sizeof(*m));
  78.     if (!m)

libavutil/dict.c:78:10: Taking false branch
  76.     if (!m)
  77.         m = *pm = av_mallocz(sizeof(*m));
  78.     if (!m)
               ^
  79.         return AVERROR(ENOMEM);
  80. 

libavutil/dict.c:81:9: Taking false branch
  79.         return AVERROR(ENOMEM);
  80. 
  81.     if (tag) {
              ^
  82.         if (flags & AV_DICT_DONT_OVERWRITE) {
  83.             if (flags & AV_DICT_DONT_STRDUP_KEY) av_free(key);

libavutil/dict.c:94:9: 
  92.         *tag = m->elems[--m->count];
  93.     } else {
  94.         int ret = av_reallocp_array(&m->elems,
              ^
  95.                                     m->count + 1, sizeof(*m->elems));
  96.         if (ret < 0) {

libavutil/mem.c:168:1: start of procedure av_reallocp_array()
    166. }
    167. 
    168. int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
         ^
    169. {
    170.     void *val;

libavutil/mem.c:172:10: Taking false branch
    170.     void *val;
    171. 
    172.     if (!size || nmemb >= INT_MAX / size)
                  ^
    173.         return AVERROR(ENOMEM);
    174.     if (!nmemb) {

libavutil/mem.c:172:18: Taking true branch
    170.     void *val;
    171. 
    172.     if (!size || nmemb >= INT_MAX / size)
                          ^
    173.         return AVERROR(ENOMEM);
    174.     if (!nmemb) {

libavutil/mem.c:173:9: 
    171. 
    172.     if (!size || nmemb >= INT_MAX / size)
    173.         return AVERROR(ENOMEM);
                 ^
    174.     if (!nmemb) {
    175.         av_freep(ptr);

libavutil/mem.c:188:1: return from a call to av_reallocp_array
    186.     memcpy(ptr, &val, sizeof(val));
    187.     return 0;
    188. }
         ^
    189. 
    190. void av_free(void *ptr)

libavutil/dict.c:96:13: Taking true branch
  94.         int ret = av_reallocp_array(&m->elems,
  95.                                     m->count + 1, sizeof(*m->elems));
  96.         if (ret < 0) {
                  ^
  97.             if (allocated)
  98.                 av_freep(pm);

libavutil/dict.c:97:17: Taking true branch
  95.                                     m->count + 1, sizeof(*m->elems));
  96.         if (ret < 0) {
  97.             if (allocated)
                      ^
  98.                 av_freep(pm);
  99. 

libavutil/dict.c:98:17: Skipping av_freep(): empty list of specs
   96.         if (ret < 0) {
   97.             if (allocated)
   98.                 av_freep(pm);
                       ^
   99. 
  100.             return ret;

libavutil/dict.c:100:13: 
   98.                 av_freep(pm);
   99. 
  100.             return ret;
                   ^
  101.         }
  102.     }

libavutil/dict.c:126:1: return from a call to av_dict_set
  124. 
  125.     return 0;
  126. }
       ^
  127. 
  128. static int parse_key_value_pair(AVDictionary **pm, const char **buf,

libavformat/hls.c:488:17: Taking true branch
486.             ret = av_dict_set(&c->avio_opts, *opt, buf,
487.                               AV_DICT_DONT_STRDUP_VAL);
488.             if (ret < 0)
                     ^
489.                 return ret;
490.         }

libavformat/hls.c:489:17: 
487.                               AV_DICT_DONT_STRDUP_VAL);
488.             if (ret < 0)
489.                 return ret;
                     ^
490.         }
491.         opt++;

libavformat/hls.c:495:1: return from a call to save_avio_options
493. 
494.     return ret;
495. }
     ^
496. 
497. static int hls_read_header(AVFormatContext *s)
