avconv_opt.c:215: error: Null Dereference
  pointer `map` last assigned on line 212 could be null and is dereferenced by call to `strchr()` at line 215, column 16.

avconv_opt.c:199:1: start of procedure opt_map()
197. }
198. 
199. static int opt_map(void *optctx, const char *opt, const char *arg)
     ^
200. {
201.     OptionsContext *o = optctx;

avconv_opt.c:201:5: 
199. static int opt_map(void *optctx, const char *opt, const char *arg)
200. {
201.     OptionsContext *o = optctx;
         ^
202.     StreamMap *m = NULL;
203.     int i, negative = 0, file_idx;

avconv_opt.c:202:5: 
200. {
201.     OptionsContext *o = optctx;
202.     StreamMap *m = NULL;
         ^
203.     int i, negative = 0, file_idx;
204.     int sync_file_idx = -1, sync_stream_idx;

avconv_opt.c:203:5: 
201.     OptionsContext *o = optctx;
202.     StreamMap *m = NULL;
203.     int i, negative = 0, file_idx;
         ^
204.     int sync_file_idx = -1, sync_stream_idx;
205.     char *p, *sync;

avconv_opt.c:204:5: 
202.     StreamMap *m = NULL;
203.     int i, negative = 0, file_idx;
204.     int sync_file_idx = -1, sync_stream_idx;
         ^
205.     char *p, *sync;
206.     char *map;

avconv_opt.c:208:9: Taking false branch
206.     char *map;
207. 
208.     if (*arg == '-') {
             ^
209.         negative = 1;
210.         arg++;

avconv_opt.c:212:5: 
210.         arg++;
211.     }
212.     map = av_strdup(arg);
         ^
213. 
214.     /* parse sync stream first, just pick first matching stream */

libavutil/mem.c:213:1: start of procedure av_strdup()
  211. }
  212. 
  213. char *av_strdup(const char *s)
       ^
  214. {
  215.     char *ptr = NULL;

libavutil/mem.c:215:5: 
  213. char *av_strdup(const char *s)
  214. {
  215.     char *ptr = NULL;
           ^
  216.     if (s) {
  217.         int len = strlen(s) + 1;

libavutil/mem.c:216:9: Taking true branch
  214. {
  215.     char *ptr = NULL;
  216.     if (s) {
               ^
  217.         int len = strlen(s) + 1;
  218.         ptr = av_realloc(NULL, len);

libavutil/mem.c:217:9: 
  215.     char *ptr = NULL;
  216.     if (s) {
  217.         int len = strlen(s) + 1;
               ^
  218.         ptr = av_realloc(NULL, len);
  219.         if (ptr)

libavutil/mem.c:218:9: 
  216.     if (s) {
  217.         int len = strlen(s) + 1;
  218.         ptr = av_realloc(NULL, len);
               ^
  219.         if (ptr)
  220.             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:219:13: Taking false branch
  217.         int len = strlen(s) + 1;
  218.         ptr = av_realloc(NULL, len);
  219.         if (ptr)
                   ^
  220.             memcpy(ptr, s, len);
  221.     }

libavutil/mem.c:222:5: 
  220.             memcpy(ptr, s, len);
  221.     }
  222.     return ptr;
           ^
  223. }
  224. 

libavutil/mem.c:223:1: return from a call to av_strdup
  221.     }
  222.     return ptr;
  223. }
       ^
  224. 
  225. static void fill16(uint8_t *dst, int len)

avconv_opt.c:215:9: 
213. 
214.     /* parse sync stream first, just pick first matching stream */
215.     if (sync = strchr(map, ',')) {
             ^
216.         *sync = 0;
217.         sync_file_idx = strtol(sync + 1, &sync, 0);

static int opt_map(void *optctx, const char *opt, const char *arg)
{
    OptionsContext *o = optctx;
    StreamMap *m = NULL;
    int i, negative = 0, file_idx;
    int sync_file_idx = -1, sync_stream_idx;
    char *p, *sync;
    char *map;
    if (*arg == '-') {
        negative = 1;
        arg++;
    }
    map = av_strdup(arg);
    if (sync = strchr(map, ',')) {
        *sync = 0;
        sync_file_idx = strtol(sync + 1, &sync, 0);
        if (sync_file_idx >= nb_input_files || sync_file_idx < 0) {
            av_log(NULL, AV_LOG_FATAL, "Invalid sync file index: %d.\n", sync_file_idx);
            exit_program(1);
        }
        if (*sync)
            sync++;
        for (i = 0; i < input_files[sync_file_idx]->nb_streams; i++)
            if (check_stream_specifier(input_files[sync_file_idx]->ctx,
                                       input_files[sync_file_idx]->ctx->streams[i], sync) == 1) {
                sync_stream_idx = i;
                break;
            }
        if (i == input_files[sync_file_idx]->nb_streams) {
            av_log(NULL, AV_LOG_FATAL, "Sync stream specification in map %s does not "
                                       "match any streams.\n", arg);
            exit_program(1);
        }
    }
    if (map[0] == '[') {
        const char *c = map + 1;
        GROW_ARRAY(o->stream_maps, o->nb_stream_maps);
        m = &o->stream_maps[o->nb_stream_maps - 1];
        m->linklabel = av_get_token(&c, "]");
        if (!m->linklabel) {
            av_log(NULL, AV_LOG_ERROR, "Invalid output link label: %s.\n", map);
            exit_program(1);
        }
    } else {
        file_idx = strtol(map, &p, 0);
        if (file_idx >= nb_input_files || file_idx < 0) {
            av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", file_idx);
            exit_program(1);
        }
        if (negative)
            for (i = 0; i < o->nb_stream_maps; i++) {
                m = &o->stream_maps[i];
                if (file_idx == m->file_index &&
                    check_stream_specifier(input_files[m->file_index]->ctx,
                                           input_files[m->file_index]->ctx->streams[m->stream_index],
                                           *p == ':' ? p + 1 : p) > 0)
                    m->disabled = 1;
            }
        else
            for (i = 0; i < input_files[file_idx]->nb_streams; i++) {
                if (check_stream_specifier(input_files[file_idx]->ctx, input_files[file_idx]->ctx->streams[i],
                            *p == ':' ? p + 1 : p) <= 0)
                    continue;
                GROW_ARRAY(o->stream_maps, o->nb_stream_maps);
                m = &o->stream_maps[o->nb_stream_maps - 1];
                m->file_index   = file_idx;
                m->stream_index = i;
                if (sync_file_idx >= 0) {
                    m->sync_file_index   = sync_file_idx;
                    m->sync_stream_index = sync_stream_idx;
                } else {
                    m->sync_file_index   = file_idx;
                    m->sync_stream_index = i;
                }
            }
    }
    if (!m) {
        av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n", arg);
        exit_program(1);
    }
    av_freep(&map);
    return 0;
}
['static int opt_map(void *optctx, const char *opt, const char *arg)\n{\n    OptionsContext *o = optctx;\n    StreamMap *m = NULL;\n    int i, negative = 0, file_idx;\n    int sync_file_idx = -1, sync_stream_idx;\n    char *p, *sync;\n    char *map;\n    if (*arg == \'-\') {\n        negative = 1;\n        arg++;\n    }\n    map = av_strdup(arg);\n    if (sync = strchr(map, \',\')) {\n        *sync = 0;\n        sync_file_idx = strtol(sync + 1, &sync, 0);\n        if (sync_file_idx >= nb_input_files || sync_file_idx < 0) {\n            av_log(NULL, AV_LOG_FATAL, "Invalid sync file index: %d.\\n", sync_file_idx);\n            exit_program(1);\n        }\n        if (*sync)\n            sync++;\n        for (i = 0; i < input_files[sync_file_idx]->nb_streams; i++)\n            if (check_stream_specifier(input_files[sync_file_idx]->ctx,\n                                       input_files[sync_file_idx]->ctx->streams[i], sync) == 1) {\n                sync_stream_idx = i;\n                break;\n            }\n        if (i == input_files[sync_file_idx]->nb_streams) {\n            av_log(NULL, AV_LOG_FATAL, "Sync stream specification in map %s does not "\n                                       "match any streams.\\n", arg);\n            exit_program(1);\n        }\n    }\n    if (map[0] == \'[\') {\n        const char *c = map + 1;\n        GROW_ARRAY(o->stream_maps, o->nb_stream_maps);\n        m = &o->stream_maps[o->nb_stream_maps - 1];\n        m->linklabel = av_get_token(&c, "]");\n        if (!m->linklabel) {\n            av_log(NULL, AV_LOG_ERROR, "Invalid output link label: %s.\\n", map);\n            exit_program(1);\n        }\n    } else {\n        file_idx = strtol(map, &p, 0);\n        if (file_idx >= nb_input_files || file_idx < 0) {\n            av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\\n", file_idx);\n            exit_program(1);\n        }\n        if (negative)\n            for (i = 0; i < o->nb_stream_maps; i++) {\n                m = &o->stream_maps[i];\n                if (file_idx == m->file_index &&\n                    check_stream_specifier(input_files[m->file_index]->ctx,\n                                           input_files[m->file_index]->ctx->streams[m->stream_index],\n                                           *p == \':\' ? p + 1 : p) > 0)\n                    m->disabled = 1;\n            }\n        else\n            for (i = 0; i < input_files[file_idx]->nb_streams; i++) {\n                if (check_stream_specifier(input_files[file_idx]->ctx, input_files[file_idx]->ctx->streams[i],\n                            *p == \':\' ? p + 1 : p) <= 0)\n                    continue;\n                GROW_ARRAY(o->stream_maps, o->nb_stream_maps);\n                m = &o->stream_maps[o->nb_stream_maps - 1];\n                m->file_index   = file_idx;\n                m->stream_index = i;\n                if (sync_file_idx >= 0) {\n                    m->sync_file_index   = sync_file_idx;\n                    m->sync_stream_index = sync_stream_idx;\n                } else {\n                    m->sync_file_index   = file_idx;\n                    m->sync_stream_index = i;\n                }\n            }\n    }\n    if (!m) {\n        av_log(NULL, AV_LOG_FATAL, "Stream map \'%s\' matches no streams.\\n", arg);\n        exit_program(1);\n    }\n    av_freep(&map);\n    return 0;\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}']