cmdutils.c:1588: error: Memory Leak
  memory dynamically allocated by call to `av_strdup()` at line 1575, column 52 is not reachable after line 1588, column 9.

cmdutils.c:1514:1: start of procedure check_stream_specifier()
1512. }
1513. 
1514. int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
      ^
1515. {
1516.     if (*spec <= '9' && *spec >= '0') /* opt:index */

cmdutils.c:1516:9: Taking false branch
1514. int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
1515. {
1516.     if (*spec <= '9' && *spec >= '0') /* opt:index */
              ^
1517.         return strtol(spec, NULL, 0) == st->index;
1518.     else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' ||

cmdutils.c:1518:14: Taking false branch
1516.     if (*spec <= '9' && *spec >= '0') /* opt:index */
1517.         return strtol(spec, NULL, 0) == st->index;
1518.     else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' ||
                   ^
1519.              *spec == 't') { /* opt:[vasdt] */
1520.         enum AVMediaType type;

cmdutils.c:1518:30: Taking false branch
1516.     if (*spec <= '9' && *spec >= '0') /* opt:index */
1517.         return strtol(spec, NULL, 0) == st->index;
1518.     else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' ||
                                   ^
1519.              *spec == 't') { /* opt:[vasdt] */
1520.         enum AVMediaType type;

cmdutils.c:1518:46: Taking false branch
1516.     if (*spec <= '9' && *spec >= '0') /* opt:index */
1517.         return strtol(spec, NULL, 0) == st->index;
1518.     else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' ||
                                                   ^
1519.              *spec == 't') { /* opt:[vasdt] */
1520.         enum AVMediaType type;

cmdutils.c:1518:62: Taking false branch
1516.     if (*spec <= '9' && *spec >= '0') /* opt:index */
1517.         return strtol(spec, NULL, 0) == st->index;
1518.     else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' ||
                                                                   ^
1519.              *spec == 't') { /* opt:[vasdt] */
1520.         enum AVMediaType type;

cmdutils.c:1519:14: Taking false branch
1517.         return strtol(spec, NULL, 0) == st->index;
1518.     else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' ||
1519.              *spec == 't') { /* opt:[vasdt] */
                   ^
1520.         enum AVMediaType type;
1521. 

cmdutils.c:1540:16: Taking false branch
1538.         }
1539.         return 1;
1540.     } else if (*spec == 'p' && *(spec + 1) == ':') {
                     ^
1541.         int prog_id, i, j;
1542.         char *endptr;

cmdutils.c:1561:16: Taking false branch
1559.         }
1560.         return 0;
1561.     } else if (*spec == 'i' && *(spec + 1) == ':') {
                     ^
1562.         int stream_id;
1563.         char *endptr;

cmdutils.c:1567:16: Taking true branch
1565.         stream_id = strtol(spec, &endptr, 0);
1566.         return stream_id == st->id;
1567.     } else if (*spec == 'm' && *(spec + 1) == ':') {
                     ^
1568.         AVDictionaryEntry *tag;
1569.         char *key, *val;

cmdutils.c:1567:32: Taking true branch
1565.         stream_id = strtol(spec, &endptr, 0);
1566.         return stream_id == st->id;
1567.     } else if (*spec == 'm' && *(spec + 1) == ':') {
                                     ^
1568.         AVDictionaryEntry *tag;
1569.         char *key, *val;

cmdutils.c:1572:9: 
1570.         int ret;
1571. 
1572.         spec += 2;
              ^
1573.         val = strchr(spec, ':');
1574. 

cmdutils.c:1573:9: 
1571. 
1572.         spec += 2;
1573.         val = strchr(spec, ':');
              ^
1574. 
1575.         key = val ? av_strndup(spec, val - spec) : av_strdup(spec);

cmdutils.c:1575:15: Condition is false
1573.         val = strchr(spec, ':');
1574. 
1575.         key = val ? av_strndup(spec, val - spec) : av_strdup(spec);
                    ^
1576.         if (!key)
1577.             return AVERROR(ENOMEM);

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)

cmdutils.c:1575:9: 
1573.         val = strchr(spec, ':');
1574. 
1575.         key = val ? av_strndup(spec, val - spec) : av_strdup(spec);
              ^
1576.         if (!key)
1577.             return AVERROR(ENOMEM);

cmdutils.c:1576:14: Taking false branch
1574. 
1575.         key = val ? av_strndup(spec, val - spec) : av_strdup(spec);
1576.         if (!key)
                   ^
1577.             return AVERROR(ENOMEM);
1578. 

cmdutils.c:1579:9: Skipping av_dict_get(): empty list of specs
1577.             return AVERROR(ENOMEM);
1578. 
1579.         tag = av_dict_get(st->metadata, key, NULL, 0);
              ^
1580.         if (tag) {
1581.             if (!val || !strcmp(tag->value, val + 1))

cmdutils.c:1580:13: Taking true branch
1578. 
1579.         tag = av_dict_get(st->metadata, key, NULL, 0);
1580.         if (tag) {
                  ^
1581.             if (!val || !strcmp(tag->value, val + 1))
1582.                 ret = 1;

cmdutils.c:1581:18: Taking false branch
1579.         tag = av_dict_get(st->metadata, key, NULL, 0);
1580.         if (tag) {
1581.             if (!val || !strcmp(tag->value, val + 1))
                       ^
1582.                 ret = 1;
1583.             else

cmdutils.c:1581:26: Taking false branch
1579.         tag = av_dict_get(st->metadata, key, NULL, 0);
1580.         if (tag) {
1581.             if (!val || !strcmp(tag->value, val + 1))
                               ^
1582.                 ret = 1;
1583.             else

cmdutils.c:1584:17: 
1582.                 ret = 1;
1583.             else
1584.                 ret = 0;
                      ^
1585.         } else
1586.             ret = 0;

cmdutils.c:1588:9: Skipping av_freep(): empty list of specs
1586.             ret = 0;
1587. 
1588.         av_freep(&key);
              ^
1589.         return ret;
1590.     } else if (!*spec) /* empty specifier, matches everything */

int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
{
    if (*spec <= '9' && *spec >= '0')
        return strtol(spec, NULL, 0) == st->index;
    else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' ||
             *spec == 't') {
        enum AVMediaType type;
        switch (*spec++) {
        case 'v': type = AVMEDIA_TYPE_VIDEO;      break;
        case 'a': type = AVMEDIA_TYPE_AUDIO;      break;
        case 's': type = AVMEDIA_TYPE_SUBTITLE;   break;
        case 'd': type = AVMEDIA_TYPE_DATA;       break;
        case 't': type = AVMEDIA_TYPE_ATTACHMENT; break;
        default:  av_assert0(0);
        }
        if (type != st->codec->codec_type)
            return 0;
        if (*spec++ == ':') {
            int i, index = strtol(spec, NULL, 0);
            for (i = 0; i < s->nb_streams; i++)
                if (s->streams[i]->codec->codec_type == type && index-- == 0)
                   return i == st->index;
            return 0;
        }
        return 1;
    } else if (*spec == 'p' && *(spec + 1) == ':') {
        int prog_id, i, j;
        char *endptr;
        spec += 2;
        prog_id = strtol(spec, &endptr, 0);
        for (i = 0; i < s->nb_programs; i++) {
            if (s->programs[i]->id != prog_id)
                continue;
            if (*endptr++ == ':') {
                int stream_idx = strtol(endptr, NULL, 0);
                return stream_idx >= 0 &&
                    stream_idx < s->programs[i]->nb_stream_indexes &&
                    st->index == s->programs[i]->stream_index[stream_idx];
            }
            for (j = 0; j < s->programs[i]->nb_stream_indexes; j++)
                if (st->index == s->programs[i]->stream_index[j])
                    return 1;
        }
        return 0;
    } else if (*spec == 'i' && *(spec + 1) == ':') {
        int stream_id;
        char *endptr;
        spec += 2;
        stream_id = strtol(spec, &endptr, 0);
        return stream_id == st->id;
    } else if (*spec == 'm' && *(spec + 1) == ':') {
        AVDictionaryEntry *tag;
        char *key, *val;
        int ret;
        spec += 2;
        val = strchr(spec, ':');
        key = val ? av_strndup(spec, val - spec) : av_strdup(spec);
        if (!key)
            return AVERROR(ENOMEM);
        tag = av_dict_get(st->metadata, key, NULL, 0);
        if (tag) {
            if (!val || !strcmp(tag->value, val + 1))
                ret = 1;
            else
                ret = 0;
        } else
            ret = 0;
        av_freep(&key);
        return ret;
    } else if (!*spec)
        return 1;
    av_log(s, AV_LOG_ERROR, "Invalid stream specifier: %s.\n", spec);
    return AVERROR(EINVAL);
}
['int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)\n{\n    if (*spec <= \'9\' && *spec >= \'0\')\n        return strtol(spec, NULL, 0) == st->index;\n    else if (*spec == \'v\' || *spec == \'a\' || *spec == \'s\' || *spec == \'d\' ||\n             *spec == \'t\') {\n        enum AVMediaType type;\n        switch (*spec++) {\n        case \'v\': type = AVMEDIA_TYPE_VIDEO;      break;\n        case \'a\': type = AVMEDIA_TYPE_AUDIO;      break;\n        case \'s\': type = AVMEDIA_TYPE_SUBTITLE;   break;\n        case \'d\': type = AVMEDIA_TYPE_DATA;       break;\n        case \'t\': type = AVMEDIA_TYPE_ATTACHMENT; break;\n        default:  av_assert0(0);\n        }\n        if (type != st->codec->codec_type)\n            return 0;\n        if (*spec++ == \':\') {\n            int i, index = strtol(spec, NULL, 0);\n            for (i = 0; i < s->nb_streams; i++)\n                if (s->streams[i]->codec->codec_type == type && index-- == 0)\n                   return i == st->index;\n            return 0;\n        }\n        return 1;\n    } else if (*spec == \'p\' && *(spec + 1) == \':\') {\n        int prog_id, i, j;\n        char *endptr;\n        spec += 2;\n        prog_id = strtol(spec, &endptr, 0);\n        for (i = 0; i < s->nb_programs; i++) {\n            if (s->programs[i]->id != prog_id)\n                continue;\n            if (*endptr++ == \':\') {\n                int stream_idx = strtol(endptr, NULL, 0);\n                return stream_idx >= 0 &&\n                    stream_idx < s->programs[i]->nb_stream_indexes &&\n                    st->index == s->programs[i]->stream_index[stream_idx];\n            }\n            for (j = 0; j < s->programs[i]->nb_stream_indexes; j++)\n                if (st->index == s->programs[i]->stream_index[j])\n                    return 1;\n        }\n        return 0;\n    } else if (*spec == \'i\' && *(spec + 1) == \':\') {\n        int stream_id;\n        char *endptr;\n        spec += 2;\n        stream_id = strtol(spec, &endptr, 0);\n        return stream_id == st->id;\n    } else if (*spec == \'m\' && *(spec + 1) == \':\') {\n        AVDictionaryEntry *tag;\n        char *key, *val;\n        int ret;\n        spec += 2;\n        val = strchr(spec, \':\');\n        key = val ? av_strndup(spec, val - spec) : av_strdup(spec);\n        if (!key)\n            return AVERROR(ENOMEM);\n        tag = av_dict_get(st->metadata, key, NULL, 0);\n        if (tag) {\n            if (!val || !strcmp(tag->value, val + 1))\n                ret = 1;\n            else\n                ret = 0;\n        } else\n            ret = 0;\n        av_freep(&key);\n        return ret;\n    } else if (!*spec)\n        return 1;\n    av_log(s, AV_LOG_ERROR, "Invalid stream specifier: %s.\\n", spec);\n    return AVERROR(EINVAL);\n}', 'char *av_strdup(const char *s)\n{\n    char *ptr = NULL;\n    if (s) {\n        int len = strlen(s) + 1;\n        ptr = av_realloc(NULL, len);\n        if (ptr)\n            memcpy(ptr, s, len);\n    }\n    return ptr;\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}']