ffmpeg.c:3640: error: Null Dereference
  pointer `streamid_map` last assigned on line 3639 could be null and is dereferenced at line 3640, column 5.

ffmpeg.c:3622:1: start of procedure opt_streamid()
3620. 
3621. /* arg format is "output-stream-index:streamid-value". */
3622. static int opt_streamid(const char *opt, const char *arg)
      ^
3623. {
3624.     int idx;

ffmpeg.c:3628:5: 
3626.     char idx_str[16];
3627. 
3628.     strncpy(idx_str, arg, sizeof(idx_str));
          ^
3629.     idx_str[sizeof(idx_str)-1] = '\0';
3630.     p = strchr(idx_str, ':');

ffmpeg.c:3629:5: 
3627. 
3628.     strncpy(idx_str, arg, sizeof(idx_str));
3629.     idx_str[sizeof(idx_str)-1] = '\0';
          ^
3630.     p = strchr(idx_str, ':');
3631.     if (!p) {

ffmpeg.c:3630:5: 
3628.     strncpy(idx_str, arg, sizeof(idx_str));
3629.     idx_str[sizeof(idx_str)-1] = '\0';
3630.     p = strchr(idx_str, ':');
          ^
3631.     if (!p) {
3632.         fprintf(stderr,

ffmpeg.c:3631:10: Taking false branch
3629.     idx_str[sizeof(idx_str)-1] = '\0';
3630.     p = strchr(idx_str, ':');
3631.     if (!p) {
               ^
3632.         fprintf(stderr,
3633.                 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",

ffmpeg.c:3637:5: 
3635.         ffmpeg_exit(1);
3636.     }
3637.     *p++ = '\0';
          ^
3638.     idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1);
3639.     streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1);

ffmpeg.c:3638:5: Skipping parse_number_or_die(): empty list of specs
3636.     }
3637.     *p++ = '\0';
3638.     idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1);
          ^
3639.     streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1);
3640.     streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX);

ffmpeg.c:3639:5: 
3637.     *p++ = '\0';
3638.     idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1);
3639.     streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1);
          ^
3640.     streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX);
3641.     return 0;

ffmpeg.c:510:1: start of procedure grow_array()
  508. 
  509. /* similar to ff_dynarray_add() and av_fast_realloc() */
  510. static void *grow_array(void *array, int elem_size, int *size, int new_size)
       ^
  511. {
  512.     if (new_size >= INT_MAX / elem_size) {

ffmpeg.c:512:9: Taking false branch
  510. static void *grow_array(void *array, int elem_size, int *size, int new_size)
  511. {
  512.     if (new_size >= INT_MAX / elem_size) {
               ^
  513.         fprintf(stderr, "Array too big.\n");
  514.         ffmpeg_exit(1);

ffmpeg.c:516:9: Taking true branch
  514.         ffmpeg_exit(1);
  515.     }
  516.     if (*size < new_size) {
               ^
  517.         uint8_t *tmp = av_realloc(array, new_size*elem_size);
  518.         if (!tmp) {

ffmpeg.c:517:9: 
  515.     }
  516.     if (*size < new_size) {
  517.         uint8_t *tmp = av_realloc(array, new_size*elem_size);
               ^
  518.         if (!tmp) {
  519.             fprintf(stderr, "Could not alloc buffer.\n");

libavutil/mem.c:119:1: start of procedure av_realloc()
    117. }
    118. 
    119. void *av_realloc(void *ptr, FF_INTERNAL_MEM_TYPE size)
         ^
    120. {
    121. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:126:8: Taking true branch
    124. 
    125.     /* let's disallow possible ambiguous cases */
    126.     if(size > (INT_MAX-16) )
                ^
    127.         return NULL;
    128. 

libavutil/mem.c:127:9: 
    125.     /* let's disallow possible ambiguous cases */
    126.     if(size > (INT_MAX-16) )
    127.         return NULL;
                 ^
    128. 
    129. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:137:1: return from a call to av_realloc
    135.     return realloc(ptr, size);
    136. #endif
    137. }
         ^
    138. 
    139. void av_free(void *ptr)

ffmpeg.c:518:14: Taking true branch
  516.     if (*size < new_size) {
  517.         uint8_t *tmp = av_realloc(array, new_size*elem_size);
  518.         if (!tmp) {
                    ^
  519.             fprintf(stderr, "Could not alloc buffer.\n");
  520.             ffmpeg_exit(1);

ffmpeg.c:519:13: 
  517.         uint8_t *tmp = av_realloc(array, new_size*elem_size);
  518.         if (!tmp) {
  519.             fprintf(stderr, "Could not alloc buffer.\n");
                   ^
  520.             ffmpeg_exit(1);
  521.         }

ffmpeg.c:520:13: Skipping ffmpeg_exit(): empty list of specs
  518.         if (!tmp) {
  519.             fprintf(stderr, "Could not alloc buffer.\n");
  520.             ffmpeg_exit(1);
                   ^
  521.         }
  522.         memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);

ffmpeg.c:522:9: 
  520.             ffmpeg_exit(1);
  521.         }
  522.         memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);
               ^
  523.         *size = new_size;
  524.         return tmp;

ffmpeg.c:523:9: 
  521.         }
  522.         memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);
  523.         *size = new_size;
               ^
  524.         return tmp;
  525.     }

ffmpeg.c:524:9: 
  522.         memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);
  523.         *size = new_size;
  524.         return tmp;
               ^
  525.     }
  526.     return array;

ffmpeg.c:527:1: return from a call to grow_array
  525.     }
  526.     return array;
  527. }
       ^
  528. 
  529. static void choose_sample_fmt(AVStream *st, AVCodec *codec)

ffmpeg.c:3640:5: Skipping parse_number_or_die(): empty list of specs
3638.     idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1);
3639.     streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1);
3640.     streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX);
          ^
3641.     return 0;
3642. }

static int opt_streamid(const char *opt, const char *arg)
{
    int idx;
    char *p;
    char idx_str[16];
    strncpy(idx_str, arg, sizeof(idx_str));
    idx_str[sizeof(idx_str)-1] = '\0';
    p = strchr(idx_str, ':');
    if (!p) {
        fprintf(stderr,
                "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
                arg, opt);
        ffmpeg_exit(1);
    }
    *p++ = '\0';
    idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1);
    streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1);
    streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX);
    return 0;
}
['static int opt_streamid(const char *opt, const char *arg)\n{\n    int idx;\n    char *p;\n    char idx_str[16];\n    strncpy(idx_str, arg, sizeof(idx_str));\n    idx_str[sizeof(idx_str)-1] = \'\\0\';\n    p = strchr(idx_str, \':\');\n    if (!p) {\n        fprintf(stderr,\n                "Invalid value \'%s\' for option \'%s\', required syntax is \'index:value\'\\n",\n                arg, opt);\n        ffmpeg_exit(1);\n    }\n    *p++ = \'\\0\';\n    idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1);\n    streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1);\n    streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX);\n    return 0;\n}', 'static void *grow_array(void *array, int elem_size, int *size, int new_size)\n{\n    if (new_size >= INT_MAX / elem_size) {\n        fprintf(stderr, "Array too big.\\n");\n        ffmpeg_exit(1);\n    }\n    if (*size < new_size) {\n        uint8_t *tmp = av_realloc(array, new_size*elem_size);\n        if (!tmp) {\n            fprintf(stderr, "Could not alloc buffer.\\n");\n            ffmpeg_exit(1);\n        }\n        memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);\n        *size = new_size;\n        return tmp;\n    }\n    return array;\n}', 'void *av_realloc(void *ptr, FF_INTERNAL_MEM_TYPE 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) return av_malloc(size);\n    diff= ((char*)ptr)[-1];\n    return (char*)realloc((char*)ptr - diff, size + diff) + diff;\n#else\n    return realloc(ptr, size);\n#endif\n}']