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

ffmpeg.c:3611:1: start of procedure opt_streamid()
3609. 
3610. /* arg format is "output-stream-index:streamid-value". */
3611. static int opt_streamid(const char *opt, const char *arg)
      ^
3612. {
3613.     int idx;

ffmpeg.c:3617:5: 
3615.     char idx_str[16];
3616. 
3617.     strncpy(idx_str, arg, sizeof(idx_str));
          ^
3618.     idx_str[sizeof(idx_str)-1] = '\0';
3619.     p = strchr(idx_str, ':');

ffmpeg.c:3618:5: 
3616. 
3617.     strncpy(idx_str, arg, sizeof(idx_str));
3618.     idx_str[sizeof(idx_str)-1] = '\0';
          ^
3619.     p = strchr(idx_str, ':');
3620.     if (!p) {

ffmpeg.c:3619:5: 
3617.     strncpy(idx_str, arg, sizeof(idx_str));
3618.     idx_str[sizeof(idx_str)-1] = '\0';
3619.     p = strchr(idx_str, ':');
          ^
3620.     if (!p) {
3621.         fprintf(stderr,

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

ffmpeg.c:3626:5: 
3624.         ffmpeg_exit(1);
3625.     }
3626.     *p++ = '\0';
          ^
3627.     idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1);
3628.     streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1);

ffmpeg.c:3627:5: Skipping parse_number_or_die(): empty list of specs
3625.     }
3626.     *p++ = '\0';
3627.     idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1);
          ^
3628.     streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1);
3629.     streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX);

ffmpeg.c:3628:5: 
3626.     *p++ = '\0';
3627.     idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1);
3628.     streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1);
          ^
3629.     streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX);
3630.     return 0;

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

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

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

ffmpeg.c:515:9: 
  513.     }
  514.     if (*size < new_size) {
  515.         uint8_t *tmp = av_realloc(array, new_size*elem_size);
               ^
  516.         if (!tmp) {
  517.             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:516:14: Taking true branch
  514.     if (*size < new_size) {
  515.         uint8_t *tmp = av_realloc(array, new_size*elem_size);
  516.         if (!tmp) {
                    ^
  517.             fprintf(stderr, "Could not alloc buffer.\n");
  518.             ffmpeg_exit(1);

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

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

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

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

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

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

ffmpeg.c:3629:5: Skipping parse_number_or_die(): empty list of specs
3627.     idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1);
3628.     streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1);
3629.     streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX);
          ^
3630.     return 0;
3631. }

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}']