libavcodec/psymodel.c:36: error: Null Dereference
  pointer `ctx->bands` last assigned on line 34 could be null and is dereferenced by call to `memcpy()` at line 36, column 5.

libavcodec/psymodel.c:28:9: start of procedure ff_psy_init()
26. extern const FFPsyModel ff_aac_psy_model;
27. 
28. av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx,
            ^
29.                         int num_lens,
30.                         const uint8_t **bands, const int* num_bands)

libavcodec/psymodel.c:32:5: 
30.                         const uint8_t **bands, const int* num_bands)
31. {
32.     ctx->avctx = avctx;
        ^
33.     ctx->psy_bands = av_mallocz(sizeof(FFPsyBand) * PSY_MAX_BANDS * avctx->channels);
34.     ctx->bands     = av_malloc (sizeof(ctx->bands[0])     * num_lens);

libavcodec/psymodel.c:33:5: 
31. {
32.     ctx->avctx = avctx;
33.     ctx->psy_bands = av_mallocz(sizeof(FFPsyBand) * PSY_MAX_BANDS * avctx->channels);
        ^
34.     ctx->bands     = av_malloc (sizeof(ctx->bands[0])     * num_lens);
35.     ctx->num_bands = av_malloc (sizeof(ctx->num_bands[0]) * num_lens);

libavutil/mem.c:140:1: start of procedure av_mallocz()
  138. }
  139. 
  140. void *av_mallocz(unsigned int size)
       ^
  141. {
  142.     void *ptr = av_malloc(size);

libavutil/mem.c:142:5: 
  140. void *av_mallocz(unsigned int size)
  141. {
  142.     void *ptr = av_malloc(size);
           ^
  143.     if (ptr)
  144.         memset(ptr, 0, size);

libavutil/mem.c:47:1: start of procedure av_malloc()
    45.    linker will do it automatically. */
    46. 
    47. void *av_malloc(unsigned int size)
        ^
    48. {
    49.     void *ptr = NULL;

libavutil/mem.c:49:5: 
    47. void *av_malloc(unsigned int size)
    48. {
    49.     void *ptr = NULL;
            ^
    50. #if CONFIG_MEMALIGN_HACK
    51.     long diff;

libavutil/mem.c:55:8: Taking true branch
    53. 
    54.     /* let's disallow possible ambiguous cases */
    55.     if(size > (INT_MAX-16) )
               ^
    56.         return NULL;
    57. 

libavutil/mem.c:56:9: 
    54.     /* let's disallow possible ambiguous cases */
    55.     if(size > (INT_MAX-16) )
    56.         return NULL;
                ^
    57. 
    58. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:100:1: return from a call to av_malloc
     98. #endif
     99.     return ptr;
    100. }
         ^
    101. 
    102. void *av_realloc(void *ptr, unsigned int size)

libavutil/mem.c:143:9: Taking false branch
  141. {
  142.     void *ptr = av_malloc(size);
  143.     if (ptr)
               ^
  144.         memset(ptr, 0, size);
  145.     return ptr;

libavutil/mem.c:145:5: 
  143.     if (ptr)
  144.         memset(ptr, 0, size);
  145.     return ptr;
           ^
  146. }
  147. 

libavutil/mem.c:146:1: return from a call to av_mallocz
  144.         memset(ptr, 0, size);
  145.     return ptr;
  146. }
       ^
  147. 
  148. char *av_strdup(const char *s)

libavcodec/psymodel.c:34:5: 
32.     ctx->avctx = avctx;
33.     ctx->psy_bands = av_mallocz(sizeof(FFPsyBand) * PSY_MAX_BANDS * avctx->channels);
34.     ctx->bands     = av_malloc (sizeof(ctx->bands[0])     * num_lens);
        ^
35.     ctx->num_bands = av_malloc (sizeof(ctx->num_bands[0]) * num_lens);
36.     memcpy(ctx->bands,     bands,     sizeof(ctx->bands[0])     *  num_lens);

libavutil/mem.c:47:1: start of procedure av_malloc()
  45.    linker will do it automatically. */
  46. 
  47. void *av_malloc(unsigned int size)
      ^
  48. {
  49.     void *ptr = NULL;

libavutil/mem.c:49:5: 
  47. void *av_malloc(unsigned int size)
  48. {
  49.     void *ptr = NULL;
          ^
  50. #if CONFIG_MEMALIGN_HACK
  51.     long diff;

libavutil/mem.c:55:8: Taking true branch
  53. 
  54.     /* let's disallow possible ambiguous cases */
  55.     if(size > (INT_MAX-16) )
             ^
  56.         return NULL;
  57. 

libavutil/mem.c:56:9: 
  54.     /* let's disallow possible ambiguous cases */
  55.     if(size > (INT_MAX-16) )
  56.         return NULL;
              ^
  57. 
  58. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:100:1: return from a call to av_malloc
   98. #endif
   99.     return ptr;
  100. }
       ^
  101. 
  102. void *av_realloc(void *ptr, unsigned int size)

libavcodec/psymodel.c:35:5: 
33.     ctx->psy_bands = av_mallocz(sizeof(FFPsyBand) * PSY_MAX_BANDS * avctx->channels);
34.     ctx->bands     = av_malloc (sizeof(ctx->bands[0])     * num_lens);
35.     ctx->num_bands = av_malloc (sizeof(ctx->num_bands[0]) * num_lens);
        ^
36.     memcpy(ctx->bands,     bands,     sizeof(ctx->bands[0])     *  num_lens);
37.     memcpy(ctx->num_bands, num_bands, sizeof(ctx->num_bands[0]) *  num_lens);

libavutil/mem.c:47:1: start of procedure av_malloc()
  45.    linker will do it automatically. */
  46. 
  47. void *av_malloc(unsigned int size)
      ^
  48. {
  49.     void *ptr = NULL;

libavutil/mem.c:49:5: 
  47. void *av_malloc(unsigned int size)
  48. {
  49.     void *ptr = NULL;
          ^
  50. #if CONFIG_MEMALIGN_HACK
  51.     long diff;

libavutil/mem.c:55:8: Taking false branch
  53. 
  54.     /* let's disallow possible ambiguous cases */
  55.     if(size > (INT_MAX-16) )
             ^
  56.         return NULL;
  57. 

libavutil/mem.c:66:9: Taking false branch
  64.     ((char*)ptr)[-1]= diff;
  65. #elif HAVE_POSIX_MEMALIGN
  66.     if (posix_memalign(&ptr,16,size))
              ^
  67.         ptr = NULL;
  68. #elif HAVE_MEMALIGN

libavutil/mem.c:99:5: 
   97.     ptr = malloc(size);
   98. #endif
   99.     return ptr;
           ^
  100. }
  101. 

libavutil/mem.c:100:1: return from a call to av_malloc
   98. #endif
   99.     return ptr;
  100. }
       ^
  101. 
  102. void *av_realloc(void *ptr, unsigned int size)

libavcodec/psymodel.c:36:5: 
34.     ctx->bands     = av_malloc (sizeof(ctx->bands[0])     * num_lens);
35.     ctx->num_bands = av_malloc (sizeof(ctx->num_bands[0]) * num_lens);
36.     memcpy(ctx->bands,     bands,     sizeof(ctx->bands[0])     *  num_lens);
        ^
37.     memcpy(ctx->num_bands, num_bands, sizeof(ctx->num_bands[0]) *  num_lens);
38.     switch (ctx->avctx->codec_id) {

int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx,
                        int num_lens,
                        const uint8_t **bands, const int* num_bands)
{
    ctx->avctx = avctx;
    ctx->psy_bands = av_mallocz(sizeof(FFPsyBand) * PSY_MAX_BANDS * avctx->channels);
    ctx->bands     = av_malloc (sizeof(ctx->bands[0])     * num_lens);
    ctx->num_bands = av_malloc (sizeof(ctx->num_bands[0]) * num_lens);
    memcpy(ctx->bands,     bands,     sizeof(ctx->bands[0])     *  num_lens);
    memcpy(ctx->num_bands, num_bands, sizeof(ctx->num_bands[0]) *  num_lens);
    switch (ctx->avctx->codec_id) {
    case CODEC_ID_AAC:
        ctx->model = &ff_aac_psy_model;
        break;
    }
    if (ctx->model->init)
        return ctx->model->init(ctx);
    return 0;
}
['int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx,\n                        int num_lens,\n                        const uint8_t **bands, const int* num_bands)\n{\n    ctx->avctx = avctx;\n    ctx->psy_bands = av_mallocz(sizeof(FFPsyBand) * PSY_MAX_BANDS * avctx->channels);\n    ctx->bands     = av_malloc (sizeof(ctx->bands[0])     * num_lens);\n    ctx->num_bands = av_malloc (sizeof(ctx->num_bands[0]) * num_lens);\n    memcpy(ctx->bands,     bands,     sizeof(ctx->bands[0])     *  num_lens);\n    memcpy(ctx->num_bands, num_bands, sizeof(ctx->num_bands[0]) *  num_lens);\n    switch (ctx->avctx->codec_id) {\n    case CODEC_ID_AAC:\n        ctx->model = &ff_aac_psy_model;\n        break;\n    }\n    if (ctx->model->init)\n        return ctx->model->init(ctx);\n    return 0;\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 = 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}']