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

libavcodec/bgmc.c:459:1: start of procedure ff_bgmc_init()
457. 
458. /** Initialize the lookup table arrays */
459. int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status)
     ^
460. {
461.     *cf_lut        = av_malloc(sizeof(*cf_lut)        * LUT_BUFF * 16 * LUT_SIZE);

libavcodec/bgmc.c:461:5: 
459. int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status)
460. {
461.     *cf_lut        = av_malloc(sizeof(*cf_lut)        * LUT_BUFF * 16 * LUT_SIZE);
         ^
462.     *cf_lut_status = av_malloc(sizeof(*cf_lut_status) * LUT_BUFF);
463. 

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:9: Taking false branch
  70. 
  71.     /* let's disallow possible ambiguous cases */
  72.     if (size > (INT_MAX-32) || !size)
              ^
  73.         return NULL;
  74. 

libavutil/mem.c:72:33: Taking false branch
  70. 
  71.     /* let's disallow possible ambiguous cases */
  72.     if (size > (INT_MAX-32) || !size)
                                      ^
  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_ALIGNED_MALLOC

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

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, size_t size)

libavcodec/bgmc.c:462:5: 
460. {
461.     *cf_lut        = av_malloc(sizeof(*cf_lut)        * LUT_BUFF * 16 * LUT_SIZE);
462.     *cf_lut_status = av_malloc(sizeof(*cf_lut_status) * LUT_BUFF);
         ^
463. 
464.     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:9: Taking false branch
  70. 
  71.     /* let's disallow possible ambiguous cases */
  72.     if (size > (INT_MAX-32) || !size)
              ^
  73.         return NULL;
  74. 

libavutil/mem.c:72:33: Taking false branch
  70. 
  71.     /* let's disallow possible ambiguous cases */
  72.     if (size > (INT_MAX-32) || !size)
                                      ^
  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_ALIGNED_MALLOC

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

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

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, size_t size)

libavcodec/bgmc.c:464:10: Taking false branch
462.     *cf_lut_status = av_malloc(sizeof(*cf_lut_status) * LUT_BUFF);
463. 
464.     if (!cf_lut || !cf_lut_status) {
              ^
465.         ff_bgmc_end(cf_lut, cf_lut_status);
466.         av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");

libavcodec/bgmc.c:464:21: Taking false branch
462.     *cf_lut_status = av_malloc(sizeof(*cf_lut_status) * LUT_BUFF);
463. 
464.     if (!cf_lut || !cf_lut_status) {
                         ^
465.         ff_bgmc_end(cf_lut, cf_lut_status);
466.         av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");

libavcodec/bgmc.c:470:9: 
468.     } else {
469.         // initialize lut_status buffer to a value never used to compare against
470.         memset(*cf_lut_status, -1, sizeof(*cf_lut_status) * LUT_BUFF);
             ^
471.     }
472. 

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) || !size)\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_ALIGNED_MALLOC\n    ptr = _aligned_malloc(size, 32);\n#elif HAVE_MEMALIGN\n    ptr = memalign(32,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}']