libavcodec/psymodel.c:39: error: Null Dereference
  pointer `ctx->bands` last assigned on line 37 could be null and is dereferenced by call to `memcpy()` at line 39, 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, int num_lens,
            ^
29.                         const uint8_t **bands, const int* num_bands,
30.                         int num_groups, const uint8_t *group_map)

libavcodec/psymodel.c:32:5: 
30.                         int num_groups, const uint8_t *group_map)
31. {
32.     int i, j, k = 0;
        ^
33. 
34.     ctx->avctx = avctx;

libavcodec/psymodel.c:34:5: 
32.     int i, j, k = 0;
33. 
34.     ctx->avctx = avctx;
        ^
35.     ctx->ch        = av_mallocz(sizeof(ctx->ch[0]) * avctx->channels * 2);
36.     ctx->group     = av_mallocz(sizeof(ctx->group[0]) * num_groups);

libavcodec/psymodel.c:35:5: 
33. 
34.     ctx->avctx = avctx;
35.     ctx->ch        = av_mallocz(sizeof(ctx->ch[0]) * avctx->channels * 2);
        ^
36.     ctx->group     = av_mallocz(sizeof(ctx->group[0]) * num_groups);
37.     ctx->bands     = av_malloc (sizeof(ctx->bands[0])     * num_lens);

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

libavutil/mem.c:158:5: 
  156. void *av_mallocz(size_t 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(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:71:5: 
    69. #endif
    70. 
    71.     assert(size);
            ^
    72. 
    73.     /* let's disallow possible ambiguous cases */

libavutil/mem.c:74:9: Taking true branch
    72. 
    73.     /* let's disallow possible ambiguous cases */
    74.     if (size > (INT_MAX-32) || !size)
                ^
    75.         return NULL;
    76. 

libavutil/mem.c:75:9: 
    73.     /* let's disallow possible ambiguous cases */
    74.     if (size > (INT_MAX-32) || !size)
    75.         return NULL;
                ^
    76. 
    77. #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, size_t 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)

libavcodec/psymodel.c:36:5: 
34.     ctx->avctx = avctx;
35.     ctx->ch        = av_mallocz(sizeof(ctx->ch[0]) * avctx->channels * 2);
36.     ctx->group     = av_mallocz(sizeof(ctx->group[0]) * num_groups);
        ^
37.     ctx->bands     = av_malloc (sizeof(ctx->bands[0])     * num_lens);
38.     ctx->num_bands = av_malloc (sizeof(ctx->num_bands[0]) * num_lens);

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

libavutil/mem.c:158:5: 
  156. void *av_mallocz(size_t 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(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:71:5: 
    69. #endif
    70. 
    71.     assert(size);
            ^
    72. 
    73.     /* let's disallow possible ambiguous cases */

libavutil/mem.c:74:9: Taking true branch
    72. 
    73.     /* let's disallow possible ambiguous cases */
    74.     if (size > (INT_MAX-32) || !size)
                ^
    75.         return NULL;
    76. 

libavutil/mem.c:75:9: 
    73.     /* let's disallow possible ambiguous cases */
    74.     if (size > (INT_MAX-32) || !size)
    75.         return NULL;
                ^
    76. 
    77. #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, size_t 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)

libavcodec/psymodel.c:37:5: 
35.     ctx->ch        = av_mallocz(sizeof(ctx->ch[0]) * avctx->channels * 2);
36.     ctx->group     = av_mallocz(sizeof(ctx->group[0]) * num_groups);
37.     ctx->bands     = av_malloc (sizeof(ctx->bands[0])     * num_lens);
        ^
38.     ctx->num_bands = av_malloc (sizeof(ctx->num_bands[0]) * num_lens);
39.     memcpy(ctx->bands,     bands,     sizeof(ctx->bands[0])     *  num_lens);

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:71:5: 
  69. #endif
  70. 
  71.     assert(size);
          ^
  72. 
  73.     /* let's disallow possible ambiguous cases */

libavutil/mem.c:74:9: Taking true branch
  72. 
  73.     /* let's disallow possible ambiguous cases */
  74.     if (size > (INT_MAX-32) || !size)
              ^
  75.         return NULL;
  76. 

libavutil/mem.c:75:9: 
  73.     /* let's disallow possible ambiguous cases */
  74.     if (size > (INT_MAX-32) || !size)
  75.         return NULL;
              ^
  76. 
  77. #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, size_t size)

libavcodec/psymodel.c:38:5: 
36.     ctx->group     = av_mallocz(sizeof(ctx->group[0]) * num_groups);
37.     ctx->bands     = av_malloc (sizeof(ctx->bands[0])     * num_lens);
38.     ctx->num_bands = av_malloc (sizeof(ctx->num_bands[0]) * num_lens);
        ^
39.     memcpy(ctx->bands,     bands,     sizeof(ctx->bands[0])     *  num_lens);
40.     memcpy(ctx->num_bands, num_bands, sizeof(ctx->num_bands[0]) *  num_lens);

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:71:5: 
  69. #endif
  70. 
  71.     assert(size);
          ^
  72. 
  73.     /* let's disallow possible ambiguous cases */

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

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

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

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/psymodel.c:39:5: 
37.     ctx->bands     = av_malloc (sizeof(ctx->bands[0])     * num_lens);
38.     ctx->num_bands = av_malloc (sizeof(ctx->num_bands[0]) * num_lens);
39.     memcpy(ctx->bands,     bands,     sizeof(ctx->bands[0])     *  num_lens);
        ^
40.     memcpy(ctx->num_bands, num_bands, sizeof(ctx->num_bands[0]) *  num_lens);
41. 
