libavcodec/bgmc.c:478: error: Null Dereference
  pointer `*cf_lut_status` last assigned on line 470 could be null and is dereferenced by call to `memset()` at line 478, column 9.

libavcodec/bgmc.c:467:1: start of procedure ff_bgmc_init()
465. /** Initialize the lookup table arrays
466.  */
467. int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status)
     ^
468. {
469.     *cf_lut        = av_malloc(sizeof(*cf_lut       ) * LUT_BUFF * 16 * LUT_SIZE);

libavcodec/bgmc.c:469:5: 
467. int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status)
468. {
469.     *cf_lut        = av_malloc(sizeof(*cf_lut       ) * LUT_BUFF * 16 * LUT_SIZE);
         ^
470.     *cf_lut_status = av_malloc(sizeof(*cf_lut_status) * LUT_BUFF);
471. 

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

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

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

libavutil/mem.c:83:9: Taking false branch
  81.     ((char*)ptr)[-1]= diff;
  82. #elif HAVE_POSIX_MEMALIGN
  83.     if (posix_memalign(&ptr,32,size))
              ^
  84.         ptr = NULL;
  85. #elif HAVE_MEMALIGN

libavutil/mem.c:114:5: 
  112.     ptr = malloc(size);
  113. #endif
  114.     return ptr;
           ^
  115. }
  116. 

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

libavcodec/bgmc.c:470:5: 
468. {
469.     *cf_lut        = av_malloc(sizeof(*cf_lut       ) * LUT_BUFF * 16 * LUT_SIZE);
470.     *cf_lut_status = av_malloc(sizeof(*cf_lut_status) * LUT_BUFF);
         ^
471. 
472.     if (!cf_lut || !cf_lut_status) {

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

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

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

libavutil/mem.c:83:9: Taking true branch
  81.     ((char*)ptr)[-1]= diff;
  82. #elif HAVE_POSIX_MEMALIGN
  83.     if (posix_memalign(&ptr,32,size))
              ^
  84.         ptr = NULL;
  85. #elif HAVE_MEMALIGN

libavutil/mem.c:84:9: 
  82. #elif HAVE_POSIX_MEMALIGN
  83.     if (posix_memalign(&ptr,32,size))
  84.         ptr = NULL;
              ^
  85. #elif HAVE_MEMALIGN
  86.     ptr = memalign(32,size);

libavutil/mem.c:114:5: 
  112.     ptr = malloc(size);
  113. #endif
  114.     return ptr;
           ^
  115. }
  116. 

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

libavcodec/bgmc.c:472:10: Taking false branch
470.     *cf_lut_status = av_malloc(sizeof(*cf_lut_status) * LUT_BUFF);
471. 
472.     if (!cf_lut || !cf_lut_status) {
              ^
473.         ff_bgmc_end(cf_lut, cf_lut_status);
474.         av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");

libavcodec/bgmc.c:472:21: Taking false branch
470.     *cf_lut_status = av_malloc(sizeof(*cf_lut_status) * LUT_BUFF);
471. 
472.     if (!cf_lut || !cf_lut_status) {
                         ^
473.         ff_bgmc_end(cf_lut, cf_lut_status);
474.         av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");

libavcodec/bgmc.c:478:9: 
476.     } else {
477.         // initialize lut_status buffer to a value never used to compare against
478.         memset(*cf_lut_status, -1, sizeof(*cf_lut_status) * LUT_BUFF);
             ^
479.     }
480. 

int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status)
{
    *cf_lut        = av_malloc(sizeof(*cf_lut       ) * LUT_BUFF * 16 * LUT_SIZE);
    *cf_lut_status = av_malloc(sizeof(*cf_lut_status) * LUT_BUFF);
    if (!cf_lut || !cf_lut_status) {
        ff_bgmc_end(cf_lut, cf_lut_status);
        av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
        return AVERROR(ENOMEM);
    } else {
        memset(*cf_lut_status, -1, sizeof(*cf_lut_status) * LUT_BUFF);
    }
    return 0;
}
['int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status)\n{\n    *cf_lut        = av_malloc(sizeof(*cf_lut       ) * LUT_BUFF * 16 * LUT_SIZE);\n    *cf_lut_status = av_malloc(sizeof(*cf_lut_status) * LUT_BUFF);\n    if (!cf_lut || !cf_lut_status) {\n        ff_bgmc_end(cf_lut, cf_lut_status);\n        av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\\n");\n        return AVERROR(ENOMEM);\n    } else {\n        memset(*cf_lut_status, -1, sizeof(*cf_lut_status) * LUT_BUFF);\n    }\n    return 0;\n}', 'void *av_malloc(size_t size)\n{\n    void *ptr = NULL;\n#if CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-32) )\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    ptr = malloc(size+32);\n    if(!ptr)\n        return ptr;\n    diff= ((-(long)ptr - 1)&31) + 1;\n    ptr = (char*)ptr + diff;\n    ((char*)ptr)[-1]= diff;\n#elif HAVE_POSIX_MEMALIGN\n    if (posix_memalign(&ptr,32,size))\n        ptr = NULL;\n#elif HAVE_MEMALIGN\n    ptr = memalign(32,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}']