libavformat/nutenc.c:625: error: Null Dereference
  pointer `nut->time_base` last assigned on line 589 could be null and is dereferenced at line 625, column 9.

libavformat/nutenc.c:580:1: start of procedure write_header()
578. }
579. 
580. static int write_header(AVFormatContext *s){
     ^
581.     NUTContext *nut = s->priv_data;
582.     AVIOContext *bc = s->pb;

libavformat/nutenc.c:581:5: 
579. 
580. static int write_header(AVFormatContext *s){
581.     NUTContext *nut = s->priv_data;
         ^
582.     AVIOContext *bc = s->pb;
583.     int i, j, ret;

libavformat/nutenc.c:582:5: 
580. static int write_header(AVFormatContext *s){
581.     NUTContext *nut = s->priv_data;
582.     AVIOContext *bc = s->pb;
         ^
583.     int i, j, ret;
584. 

libavformat/nutenc.c:585:5: 
583.     int i, j, ret;
584. 
585.     nut->avf= s;
         ^
586. 
587.     nut->stream   = av_mallocz(sizeof(StreamContext)*s->nb_streams);

libavformat/nutenc.c:587:5: 
585.     nut->avf= s;
586. 
587.     nut->stream   = av_mallocz(sizeof(StreamContext)*s->nb_streams);
         ^
588.     nut->chapter  = av_mallocz(sizeof(ChapterContext)*s->nb_chapters);
589.     nut->time_base= av_mallocz(sizeof(AVRational   )*(s->nb_streams +

libavutil/mem.c:156:1: start of procedure av_mallocz()
  154. }
  155. 
  156. void *av_mallocz(FF_INTERNAL_MEM_TYPE size)
       ^
  157. {
  158.     void *ptr = av_malloc(size);

libavutil/mem.c:158:5: 
  156. void *av_mallocz(FF_INTERNAL_MEM_TYPE size)
  157. {
  158.     void *ptr = av_malloc(size);
           ^
  159.     if (ptr)
  160.         memset(ptr, 0, size);

libavutil/mem.c:64:1: start of procedure av_malloc()
    62.    linker will do it automatically. */
    63. 
    64. void *av_malloc(FF_INTERNAL_MEM_TYPE size)
        ^
    65. {
    66.     void *ptr = NULL;

libavutil/mem.c:66:5: 
    64. void *av_malloc(FF_INTERNAL_MEM_TYPE size)
    65. {
    66.     void *ptr = NULL;
            ^
    67. #if CONFIG_MEMALIGN_HACK
    68.     long diff;

libavutil/mem.c:72:8: Taking true branch
    70. 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-16) )
               ^
    73.         return NULL;
    74. 

libavutil/mem.c:73:9: 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-16) )
    73.         return NULL;
                ^
    74. 
    75. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:117:1: return from a call to av_malloc
    115. #endif
    116.     return ptr;
    117. }
         ^
    118. 
    119. void *av_realloc(void *ptr, FF_INTERNAL_MEM_TYPE size)

libavutil/mem.c:159:9: Taking false branch
  157. {
  158.     void *ptr = av_malloc(size);
  159.     if (ptr)
               ^
  160.         memset(ptr, 0, size);
  161.     return ptr;

libavutil/mem.c:161:5: 
  159.     if (ptr)
  160.         memset(ptr, 0, size);
  161.     return ptr;
           ^
  162. }
  163. 

libavutil/mem.c:162:1: return from a call to av_mallocz
  160.         memset(ptr, 0, size);
  161.     return ptr;
  162. }
       ^
  163. 
  164. char *av_strdup(const char *s)

libavformat/nutenc.c:588:5: 
586. 
587.     nut->stream   = av_mallocz(sizeof(StreamContext)*s->nb_streams);
588.     nut->chapter  = av_mallocz(sizeof(ChapterContext)*s->nb_chapters);
         ^
589.     nut->time_base= av_mallocz(sizeof(AVRational   )*(s->nb_streams +
590.                                                       s->nb_chapters));

libavutil/mem.c:156:1: start of procedure av_mallocz()
  154. }
  155. 
  156. void *av_mallocz(FF_INTERNAL_MEM_TYPE size)
       ^
  157. {
  158.     void *ptr = av_malloc(size);

libavutil/mem.c:158:5: 
  156. void *av_mallocz(FF_INTERNAL_MEM_TYPE size)
  157. {
  158.     void *ptr = av_malloc(size);
           ^
  159.     if (ptr)
  160.         memset(ptr, 0, size);

libavutil/mem.c:64:1: start of procedure av_malloc()
    62.    linker will do it automatically. */
    63. 
    64. void *av_malloc(FF_INTERNAL_MEM_TYPE size)
        ^
    65. {
    66.     void *ptr = NULL;

libavutil/mem.c:66:5: 
    64. void *av_malloc(FF_INTERNAL_MEM_TYPE size)
    65. {
    66.     void *ptr = NULL;
            ^
    67. #if CONFIG_MEMALIGN_HACK
    68.     long diff;

libavutil/mem.c:72:8: Taking true branch
    70. 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-16) )
               ^
    73.         return NULL;
    74. 

libavutil/mem.c:73:9: 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-16) )
    73.         return NULL;
                ^
    74. 
    75. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:117:1: return from a call to av_malloc
    115. #endif
    116.     return ptr;
    117. }
         ^
    118. 
    119. void *av_realloc(void *ptr, FF_INTERNAL_MEM_TYPE size)

libavutil/mem.c:159:9: Taking false branch
  157. {
  158.     void *ptr = av_malloc(size);
  159.     if (ptr)
               ^
  160.         memset(ptr, 0, size);
  161.     return ptr;

libavutil/mem.c:161:5: 
  159.     if (ptr)
  160.         memset(ptr, 0, size);
  161.     return ptr;
           ^
  162. }
  163. 

libavutil/mem.c:162:1: return from a call to av_mallocz
  160.         memset(ptr, 0, size);
  161.     return ptr;
  162. }
       ^
  163. 
  164. char *av_strdup(const char *s)

libavformat/nutenc.c:589:5: 
587.     nut->stream   = av_mallocz(sizeof(StreamContext)*s->nb_streams);
588.     nut->chapter  = av_mallocz(sizeof(ChapterContext)*s->nb_chapters);
589.     nut->time_base= av_mallocz(sizeof(AVRational   )*(s->nb_streams +
         ^
590.                                                       s->nb_chapters));
591. 

libavutil/mem.c:156:1: start of procedure av_mallocz()
  154. }
  155. 
  156. void *av_mallocz(FF_INTERNAL_MEM_TYPE size)
       ^
  157. {
  158.     void *ptr = av_malloc(size);

libavutil/mem.c:158:5: 
  156. void *av_mallocz(FF_INTERNAL_MEM_TYPE size)
  157. {
  158.     void *ptr = av_malloc(size);
           ^
  159.     if (ptr)
  160.         memset(ptr, 0, size);

libavutil/mem.c:64:1: start of procedure av_malloc()
    62.    linker will do it automatically. */
    63. 
    64. void *av_malloc(FF_INTERNAL_MEM_TYPE size)
        ^
    65. {
    66.     void *ptr = NULL;

libavutil/mem.c:66:5: 
    64. void *av_malloc(FF_INTERNAL_MEM_TYPE size)
    65. {
    66.     void *ptr = NULL;
            ^
    67. #if CONFIG_MEMALIGN_HACK
    68.     long diff;

libavutil/mem.c:72:8: Taking true branch
    70. 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-16) )
               ^
    73.         return NULL;
    74. 

libavutil/mem.c:73:9: 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-16) )
    73.         return NULL;
                ^
    74. 
    75. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:117:1: return from a call to av_malloc
    115. #endif
    116.     return ptr;
    117. }
         ^
    118. 
    119. void *av_realloc(void *ptr, FF_INTERNAL_MEM_TYPE size)

libavutil/mem.c:159:9: Taking false branch
  157. {
  158.     void *ptr = av_malloc(size);
  159.     if (ptr)
               ^
  160.         memset(ptr, 0, size);
  161.     return ptr;

libavutil/mem.c:161:5: 
  159.     if (ptr)
  160.         memset(ptr, 0, size);
  161.     return ptr;
           ^
  162. }
  163. 

libavutil/mem.c:162:1: return from a call to av_mallocz
  160.         memset(ptr, 0, size);
  161.     return ptr;
  162. }
       ^
  163. 
  164. char *av_strdup(const char *s)

libavformat/nutenc.c:592:9: 
590.                                                       s->nb_chapters));
591. 
592.     for(i=0; i<s->nb_streams; i++){
             ^
593.         AVStream *st= s->streams[i];
594.         int ssize;

libavformat/nutenc.c:592:14: Loop condition is false. Leaving loop
590.                                                       s->nb_chapters));
591. 
592.     for(i=0; i<s->nb_streams; i++){
                  ^
593.         AVStream *st= s->streams[i];
594.         int ssize;

libavformat/nutenc.c:617:10: 
615.     }
616. 
617.     for (i = 0; i < s->nb_chapters; i++) {
              ^
618.         AVChapter *ch = s->chapters[i];
619. 

libavformat/nutenc.c:617:17: Loop condition is true. Entering loop body
615.     }
616. 
617.     for (i = 0; i < s->nb_chapters; i++) {
                     ^
618.         AVChapter *ch = s->chapters[i];
619. 

libavformat/nutenc.c:618:9: 
616. 
617.     for (i = 0; i < s->nb_chapters; i++) {
618.         AVChapter *ch = s->chapters[i];
             ^
619. 
620.         for (j = 0; j < nut->time_base_count; j++) {

libavformat/nutenc.c:620:14: 
618.         AVChapter *ch = s->chapters[i];
619. 
620.         for (j = 0; j < nut->time_base_count; j++) {
                  ^
621.             if (!memcmp(&ch->time_base, &nut->time_base[j], sizeof(AVRational)))
622.                 break;

libavformat/nutenc.c:620:21: Loop condition is false. Leaving loop
618.         AVChapter *ch = s->chapters[i];
619. 
620.         for (j = 0; j < nut->time_base_count; j++) {
                         ^
621.             if (!memcmp(&ch->time_base, &nut->time_base[j], sizeof(AVRational)))
622.                 break;

libavformat/nutenc.c:625:9: 
623.         }
624. 
625.         nut->time_base[j] = ch->time_base;
             ^
626.         nut->chapter[i].time_base = &nut->time_base[j];
627.         if(j == nut->time_base_count)

static int write_header(AVFormatContext *s){
    NUTContext *nut = s->priv_data;
    AVIOContext *bc = s->pb;
    int i, j, ret;
    nut->avf= s;
    nut->stream   = av_mallocz(sizeof(StreamContext)*s->nb_streams);
    nut->chapter  = av_mallocz(sizeof(ChapterContext)*s->nb_chapters);
    nut->time_base= av_mallocz(sizeof(AVRational   )*(s->nb_streams +
                                                      s->nb_chapters));
    for(i=0; i<s->nb_streams; i++){
        AVStream *st= s->streams[i];
        int ssize;
        AVRational time_base;
        ff_parse_specific_params(st->codec, &time_base.den, &ssize, &time_base.num);
        av_set_pts_info(st, 64, time_base.num, time_base.den);
        for(j=0; j<nut->time_base_count; j++){
            if(!memcmp(&time_base, &nut->time_base[j], sizeof(AVRational))){
                break;
            }
        }
        nut->time_base[j]= time_base;
        nut->stream[i].time_base= &nut->time_base[j];
        if(j==nut->time_base_count)
            nut->time_base_count++;
        if(INT64_C(1000) * time_base.num >= time_base.den)
            nut->stream[i].msb_pts_shift = 7;
        else
            nut->stream[i].msb_pts_shift = 14;
        nut->stream[i].max_pts_distance= FFMAX(time_base.den, time_base.num) / time_base.num;
    }
    for (i = 0; i < s->nb_chapters; i++) {
        AVChapter *ch = s->chapters[i];
        for (j = 0; j < nut->time_base_count; j++) {
            if (!memcmp(&ch->time_base, &nut->time_base[j], sizeof(AVRational)))
                break;
        }
        nut->time_base[j] = ch->time_base;
        nut->chapter[i].time_base = &nut->time_base[j];
        if(j == nut->time_base_count)
            nut->time_base_count++;
    }
    nut->max_distance = MAX_DISTANCE;
    build_elision_headers(s);
    build_frame_code(s);
    assert(nut->frame_code['N'].flags == FLAG_INVALID);
    avio_write(bc, ID_STRING, strlen(ID_STRING));
    avio_w8(bc, 0);
    if ((ret = write_headers(s, bc)) < 0)
        return ret;
    avio_flush(bc);
    return 0;
}
["static int write_header(AVFormatContext *s){\n    NUTContext *nut = s->priv_data;\n    AVIOContext *bc = s->pb;\n    int i, j, ret;\n    nut->avf= s;\n    nut->stream   = av_mallocz(sizeof(StreamContext)*s->nb_streams);\n    nut->chapter  = av_mallocz(sizeof(ChapterContext)*s->nb_chapters);\n    nut->time_base= av_mallocz(sizeof(AVRational   )*(s->nb_streams +\n                                                      s->nb_chapters));\n    for(i=0; i<s->nb_streams; i++){\n        AVStream *st= s->streams[i];\n        int ssize;\n        AVRational time_base;\n        ff_parse_specific_params(st->codec, &time_base.den, &ssize, &time_base.num);\n        av_set_pts_info(st, 64, time_base.num, time_base.den);\n        for(j=0; j<nut->time_base_count; j++){\n            if(!memcmp(&time_base, &nut->time_base[j], sizeof(AVRational))){\n                break;\n            }\n        }\n        nut->time_base[j]= time_base;\n        nut->stream[i].time_base= &nut->time_base[j];\n        if(j==nut->time_base_count)\n            nut->time_base_count++;\n        if(INT64_C(1000) * time_base.num >= time_base.den)\n            nut->stream[i].msb_pts_shift = 7;\n        else\n            nut->stream[i].msb_pts_shift = 14;\n        nut->stream[i].max_pts_distance= FFMAX(time_base.den, time_base.num) / time_base.num;\n    }\n    for (i = 0; i < s->nb_chapters; i++) {\n        AVChapter *ch = s->chapters[i];\n        for (j = 0; j < nut->time_base_count; j++) {\n            if (!memcmp(&ch->time_base, &nut->time_base[j], sizeof(AVRational)))\n                break;\n        }\n        nut->time_base[j] = ch->time_base;\n        nut->chapter[i].time_base = &nut->time_base[j];\n        if(j == nut->time_base_count)\n            nut->time_base_count++;\n    }\n    nut->max_distance = MAX_DISTANCE;\n    build_elision_headers(s);\n    build_frame_code(s);\n    assert(nut->frame_code['N'].flags == FLAG_INVALID);\n    avio_write(bc, ID_STRING, strlen(ID_STRING));\n    avio_w8(bc, 0);\n    if ((ret = write_headers(s, bc)) < 0)\n        return ret;\n    avio_flush(bc);\n    return 0;\n}", 'void *av_mallocz(FF_INTERNAL_MEM_TYPE size)\n{\n    void *ptr = av_malloc(size);\n    if (ptr)\n        memset(ptr, 0, size);\n    return ptr;\n}', 'void *av_malloc(FF_INTERNAL_MEM_TYPE size)\n{\n    void *ptr = NULL;\n#if CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    ptr = malloc(size+16);\n    if(!ptr)\n        return ptr;\n    diff= ((-(long)ptr - 1)&15) + 1;\n    ptr = (char*)ptr + diff;\n    ((char*)ptr)[-1]= diff;\n#elif HAVE_POSIX_MEMALIGN\n    if (posix_memalign(&ptr,16,size))\n        ptr = NULL;\n#elif HAVE_MEMALIGN\n    ptr = memalign(16,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}']