libavcodec/lclenc.c:174: error: Null Dereference
  pointer `avctx->extradata` last assigned on line 156 could be null and is dereferenced at line 174, column 5.

libavcodec/lclenc.c:142:1: start of procedure encode_init()
140.  *
141.  */
142. static av_cold int encode_init(AVCodecContext *avctx)
     ^
143. {
144.     LclEncContext *c = avctx->priv_data;

libavcodec/lclenc.c:144:5: 
142. static av_cold int encode_init(AVCodecContext *avctx)
143. {
144.     LclEncContext *c = avctx->priv_data;
         ^
145.     int zret; // Zlib return code
146. 

libavcodec/lclenc.c:152:5: 
150. #else
151. 
152.     c->avctx= avctx;
         ^
153. 
154.     assert(avctx->width && avctx->height);

libavcodec/lclenc.c:154:5: 
152.     c->avctx= avctx;
153. 
154.     assert(avctx->width && avctx->height);
         ^
155. 
156.     avctx->extradata= av_mallocz(8);

libavcodec/lclenc.c:156:5: 
154.     assert(avctx->width && avctx->height);
155. 
156.     avctx->extradata= av_mallocz(8);
         ^
157.     avctx->coded_frame= &c->pic;
158. 

libavutil/mem.c:132:1: start of procedure av_mallocz()
  130. }
  131. 
  132. void *av_mallocz(unsigned int size)
       ^
  133. {
  134.     void *ptr = av_malloc(size);

libavutil/mem.c:134:5: 
  132. void *av_mallocz(unsigned int size)
  133. {
  134.     void *ptr = av_malloc(size);
           ^
  135.     if (ptr)
  136.         memset(ptr, 0, size);

libavutil/mem.c:42:1: start of procedure av_malloc()
    40.    linker will do it automatically */
    41. 
    42. void *av_malloc(unsigned int size)
        ^
    43. {
    44.     void *ptr;

libavutil/mem.c:50:8: Taking false branch
    48. 
    49.     /* let's disallow possible ambiguous cases */
    50.     if(size > (INT_MAX-16) )
               ^
    51.         return NULL;
    52. 

libavutil/mem.c:61:5: Skipping memalign(): method has no implementation
    59.     ((char*)ptr)[-1]= diff;
    60. #elif defined (HAVE_MEMALIGN)
    61.     ptr = memalign(16,size);
            ^
    62.     /* Why 64?
    63.        Indeed, we should align it:

libavutil/mem.c:91:5: 
    89.     ptr = malloc(size);
    90. #endif
    91.     return ptr;
            ^
    92. }
    93. 

libavutil/mem.c:92:1: return from a call to av_malloc
    90. #endif
    91.     return ptr;
    92. }
        ^
    93. 
    94. void *av_realloc(void *ptr, unsigned int size)

libavutil/mem.c:135:9: Taking false branch
  133. {
  134.     void *ptr = av_malloc(size);
  135.     if (ptr)
               ^
  136.         memset(ptr, 0, size);
  137.     return ptr;

libavutil/mem.c:137:5: 
  135.     if (ptr)
  136.         memset(ptr, 0, size);
  137.     return ptr;
           ^
  138. }
  139. 

libavutil/mem.c:138:1: return from a call to av_mallocz
  136.         memset(ptr, 0, size);
  137.     return ptr;
  138. }
       ^
  139. 
  140. char *av_strdup(const char *s)

libavcodec/lclenc.c:157:5: 
155. 
156.     avctx->extradata= av_mallocz(8);
157.     avctx->coded_frame= &c->pic;
         ^
158. 
159.     // Will be user settable someday

libavcodec/lclenc.c:160:5: 
158. 
159.     // Will be user settable someday
160.     c->compression = 6;
         ^
161.     c->flags = 0;
162. 

libavcodec/lclenc.c:161:5: 
159.     // Will be user settable someday
160.     c->compression = 6;
161.     c->flags = 0;
         ^
162. 
163.     switch(avctx->pix_fmt){

libavcodec/lclenc.c:163:5: 
161.     c->flags = 0;
162. 
163.     switch(avctx->pix_fmt){
         ^
164.         case PIX_FMT_BGR24:
165.             c->imgtype = IMGTYPE_RGB24;

libavcodec/lclenc.c:164:9: Switch condition is true. Entering switch case
162. 
163.     switch(avctx->pix_fmt){
164.         case PIX_FMT_BGR24:
             ^
165.             c->imgtype = IMGTYPE_RGB24;
166.             c->decomp_size = avctx->width * avctx->height * 3;

libavcodec/lclenc.c:165:13: 
163.     switch(avctx->pix_fmt){
164.         case PIX_FMT_BGR24:
165.             c->imgtype = IMGTYPE_RGB24;
                 ^
166.             c->decomp_size = avctx->width * avctx->height * 3;
167.             avctx->bits_per_coded_sample= 24;

libavcodec/lclenc.c:166:13: 
164.         case PIX_FMT_BGR24:
165.             c->imgtype = IMGTYPE_RGB24;
166.             c->decomp_size = avctx->width * avctx->height * 3;
                 ^
167.             avctx->bits_per_coded_sample= 24;
168.             break;

libavcodec/lclenc.c:167:13: 
165.             c->imgtype = IMGTYPE_RGB24;
166.             c->decomp_size = avctx->width * avctx->height * 3;
167.             avctx->bits_per_coded_sample= 24;
                 ^
168.             break;
169.         default:

libavcodec/lclenc.c:174:5: 
172.     }
173. 
174.     ((uint8_t*)avctx->extradata)[0]= 4;
         ^
175.     ((uint8_t*)avctx->extradata)[1]= 0;
176.     ((uint8_t*)avctx->extradata)[2]= 0;

static av_cold int encode_init(AVCodecContext *avctx)
{
    LclEncContext *c = avctx->priv_data;
    int zret;
#ifndef CONFIG_ZLIB
    av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled.\n");
    return 1;
#else
    c->avctx= avctx;
    assert(avctx->width && avctx->height);
    avctx->extradata= av_mallocz(8);
    avctx->coded_frame= &c->pic;
    c->compression = 6;
    c->flags = 0;
    switch(avctx->pix_fmt){
        case PIX_FMT_BGR24:
            c->imgtype = IMGTYPE_RGB24;
            c->decomp_size = avctx->width * avctx->height * 3;
            avctx->bits_per_coded_sample= 24;
            break;
        default:
            av_log(avctx, AV_LOG_ERROR, "Input pixel format %s not supported\n", avcodec_get_pix_fmt_name(avctx->pix_fmt));
            return -1;
    }
    ((uint8_t*)avctx->extradata)[0]= 4;
    ((uint8_t*)avctx->extradata)[1]= 0;
    ((uint8_t*)avctx->extradata)[2]= 0;
    ((uint8_t*)avctx->extradata)[3]= 0;
    ((uint8_t*)avctx->extradata)[4]= c->imgtype;
    ((uint8_t*)avctx->extradata)[5]= c->compression;
    ((uint8_t*)avctx->extradata)[6]= c->flags;
    ((uint8_t*)avctx->extradata)[7]= CODEC_ZLIB;
    c->avctx->extradata_size= 8;
    c->zstream.zalloc = Z_NULL;
    c->zstream.zfree = Z_NULL;
    c->zstream.opaque = Z_NULL;
    zret = deflateInit(&(c->zstream), c->compression);
    if (zret != Z_OK) {
        av_log(avctx, AV_LOG_ERROR, "Deflate init error: %d\n", zret);
        return 1;
    }
        c->max_comp_size = c->decomp_size + ((c->decomp_size + 7) >> 3) +
                           ((c->decomp_size + 63) >> 6) + 11;
    if ((c->comp_buf = av_malloc(c->max_comp_size)) == NULL) {
        av_log(avctx, AV_LOG_ERROR, "Can't allocate compression buffer.\n");
        return 1;
    }
    return 0;
#endif
}
['static av_cold int encode_init(AVCodecContext *avctx)\n{\n    LclEncContext *c = avctx->priv_data;\n    int zret;\n#ifndef CONFIG_ZLIB\n    av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled.\\n");\n    return 1;\n#else\n    c->avctx= avctx;\n    assert(avctx->width && avctx->height);\n    avctx->extradata= av_mallocz(8);\n    avctx->coded_frame= &c->pic;\n    c->compression = 6;\n    c->flags = 0;\n    switch(avctx->pix_fmt){\n        case PIX_FMT_BGR24:\n            c->imgtype = IMGTYPE_RGB24;\n            c->decomp_size = avctx->width * avctx->height * 3;\n            avctx->bits_per_coded_sample= 24;\n            break;\n        default:\n            av_log(avctx, AV_LOG_ERROR, "Input pixel format %s not supported\\n", avcodec_get_pix_fmt_name(avctx->pix_fmt));\n            return -1;\n    }\n    ((uint8_t*)avctx->extradata)[0]= 4;\n    ((uint8_t*)avctx->extradata)[1]= 0;\n    ((uint8_t*)avctx->extradata)[2]= 0;\n    ((uint8_t*)avctx->extradata)[3]= 0;\n    ((uint8_t*)avctx->extradata)[4]= c->imgtype;\n    ((uint8_t*)avctx->extradata)[5]= c->compression;\n    ((uint8_t*)avctx->extradata)[6]= c->flags;\n    ((uint8_t*)avctx->extradata)[7]= CODEC_ZLIB;\n    c->avctx->extradata_size= 8;\n    c->zstream.zalloc = Z_NULL;\n    c->zstream.zfree = Z_NULL;\n    c->zstream.opaque = Z_NULL;\n    zret = deflateInit(&(c->zstream), c->compression);\n    if (zret != Z_OK) {\n        av_log(avctx, AV_LOG_ERROR, "Deflate init error: %d\\n", zret);\n        return 1;\n    }\n        c->max_comp_size = c->decomp_size + ((c->decomp_size + 7) >> 3) +\n                           ((c->decomp_size + 63) >> 6) + 11;\n    if ((c->comp_buf = av_malloc(c->max_comp_size)) == NULL) {\n        av_log(avctx, AV_LOG_ERROR, "Can\'t allocate compression buffer.\\n");\n        return 1;\n    }\n    return 0;\n#endif\n}', 'void *av_mallocz(unsigned int size)\n{\n    void *ptr = av_malloc(size);\n    if (ptr)\n        memset(ptr, 0, size);\n    return ptr;\n}', 'void *av_malloc(unsigned int size)\n{\n    void *ptr;\n#ifdef CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#ifdef 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 defined (HAVE_MEMALIGN)\n    ptr = memalign(16,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}']