libavcodec/psymodel.c:48: error: Null Dereference
  pointer `ctx->group` last assigned on line 36 could be null and is dereferenced at line 48, column 9.

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:154:1: start of procedure av_mallocz()
  152. }
  153. 
  154. void *av_mallocz(size_t size)
       ^
  155. {
  156.     void *ptr = av_malloc(size);

libavutil/mem.c:156:5: 
  154. void *av_mallocz(size_t size)
  155. {
  156.     void *ptr = av_malloc(size);
           ^
  157.     if (ptr)
  158.         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:72:8: Taking true branch
    70. 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-32) )
               ^
    73.         return NULL;
    74. 

libavutil/mem.c:73:9: 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-32) )
    73.         return NULL;
                ^
    74. 
    75. #if CONFIG_MEMALIGN_HACK

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)

libavutil/mem.c:157:9: Taking false branch
  155. {
  156.     void *ptr = av_malloc(size);
  157.     if (ptr)
               ^
  158.         memset(ptr, 0, size);
  159.     return ptr;

libavutil/mem.c:159:5: 
  157.     if (ptr)
  158.         memset(ptr, 0, size);
  159.     return ptr;
           ^
  160. }
  161. 

libavutil/mem.c:160:1: return from a call to av_mallocz
  158.         memset(ptr, 0, size);
  159.     return ptr;
  160. }
       ^
  161. 
  162. 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:154:1: start of procedure av_mallocz()
  152. }
  153. 
  154. void *av_mallocz(size_t size)
       ^
  155. {
  156.     void *ptr = av_malloc(size);

libavutil/mem.c:156:5: 
  154. void *av_mallocz(size_t size)
  155. {
  156.     void *ptr = av_malloc(size);
           ^
  157.     if (ptr)
  158.         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:72:8: Taking true branch
    70. 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-32) )
               ^
    73.         return NULL;
    74. 

libavutil/mem.c:73:9: 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-32) )
    73.         return NULL;
                ^
    74. 
    75. #if CONFIG_MEMALIGN_HACK

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)

libavutil/mem.c:157:9: Taking false branch
  155. {
  156.     void *ptr = av_malloc(size);
  157.     if (ptr)
               ^
  158.         memset(ptr, 0, size);
  159.     return ptr;

libavutil/mem.c:159:5: 
  157.     if (ptr)
  158.         memset(ptr, 0, size);
  159.     return ptr;
           ^
  160. }
  161. 

libavutil/mem.c:160:1: return from a call to av_mallocz
  158.         memset(ptr, 0, size);
  159.     return ptr;
  160. }
       ^
  161. 
  162. 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: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/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: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/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. 

libavcodec/psymodel.c:40:5: 
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. 
42.     /* assign channels to groups (with virtual channels for coupling) */

libavcodec/psymodel.c:43:10: 
41. 
42.     /* assign channels to groups (with virtual channels for coupling) */
43.     for (i = 0; i < num_groups; i++) {
             ^
44.         /* NOTE: Add 1 to handle the AAC chan_config without modification.
45.          *       This has the side effect of allowing an array of 0s to map

libavcodec/psymodel.c:43:17: Loop condition is true. Entering loop body
41. 
42.     /* assign channels to groups (with virtual channels for coupling) */
43.     for (i = 0; i < num_groups; i++) {
                    ^
44.         /* NOTE: Add 1 to handle the AAC chan_config without modification.
45.          *       This has the side effect of allowing an array of 0s to map

libavcodec/psymodel.c:48:9: 
46.          *       to one channel per group.
47.          */
48.         ctx->group[i].num_ch = group_map[i] + 1;
            ^
49.         for (j = 0; j < ctx->group[i].num_ch * 2; j++)
50.             ctx->group[i].ch[j]  = &ctx->ch[k++];

int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens,
                        const uint8_t **bands, const int* num_bands,
                        int num_groups, const uint8_t *group_map)
{
    int i, j, k = 0;
    ctx->avctx = avctx;
    ctx->ch        = av_mallocz(sizeof(ctx->ch[0]) * avctx->channels * 2);
    ctx->group     = av_mallocz(sizeof(ctx->group[0]) * num_groups);
    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);
    for (i = 0; i < num_groups; i++) {
        ctx->group[i].num_ch = group_map[i] + 1;
        for (j = 0; j < ctx->group[i].num_ch * 2; j++)
            ctx->group[i].ch[j]  = &ctx->ch[k++];
    }
    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, int num_lens,\n                        const uint8_t **bands, const int* num_bands,\n                        int num_groups, const uint8_t *group_map)\n{\n    int i, j, k = 0;\n    ctx->avctx = avctx;\n    ctx->ch        = av_mallocz(sizeof(ctx->ch[0]) * avctx->channels * 2);\n    ctx->group     = av_mallocz(sizeof(ctx->group[0]) * num_groups);\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    for (i = 0; i < num_groups; i++) {\n        ctx->group[i].num_ch = group_map[i] + 1;\n        for (j = 0; j < ctx->group[i].num_ch * 2; j++)\n            ctx->group[i].ch[j]  = &ctx->ch[k++];\n    }\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(size_t size)\n{\n    void *ptr = av_malloc(size);\n    if (ptr)\n        memset(ptr, 0, size);\n    return ptr;\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}']