libavcodec/roqvideoenc.c:844: error: Null Dereference
  pointer `points` last assigned on line 835 could be null and is dereferenced at line 844, column 9.

libavcodec/roqvideoenc.c:827:1: start of procedure generate_new_codebooks()
825. }
826. 
827. static void generate_new_codebooks(RoqContext *enc, roq_tempdata_t *tempData)
     ^
828. {
829.     int i,j;

libavcodec/roqvideoenc.c:830:5: 
828. {
829.     int i,j;
830.     roq_codebooks_t *codebooks = &tempData->codebooks;
         ^
831.     int max = enc->width*enc->height/16;
832.     uint8_t mb2[3*4];

libavcodec/roqvideoenc.c:831:5: 
829.     int i,j;
830.     roq_codebooks_t *codebooks = &tempData->codebooks;
831.     int max = enc->width*enc->height/16;
         ^
832.     uint8_t mb2[3*4];
833.     roq_cell *results4 = av_malloc(sizeof(roq_cell)*MAX_CBS_4x4*4);

libavcodec/roqvideoenc.c:833:5: 
831.     int max = enc->width*enc->height/16;
832.     uint8_t mb2[3*4];
833.     roq_cell *results4 = av_malloc(sizeof(roq_cell)*MAX_CBS_4x4*4);
         ^
834.     uint8_t *yuvClusters=av_malloc(sizeof(int)*max*6*4);
835.     int *points = av_malloc(max*6*4*sizeof(int));

libavutil/mem.c:42:1: start of procedure av_malloc()
  40.    linker will do it automatically */
  41. 
  42. void *av_malloc(unsigned int size)
      ^
  43. {
  44.     void *ptr;

libavutil/mem.c:50:8: Taking false branch
  48. 
  49.     /* let's disallow possible ambiguous cases */
  50.     if(size > (INT_MAX-16) )
             ^
  51.         return NULL;
  52. 

libavutil/mem.c:61:5: Skipping memalign(): method has no implementation
  59.     ((char*)ptr)[-1]= diff;
  60. #elif defined (HAVE_MEMALIGN)
  61.     ptr = memalign(16,size);
          ^
  62.     /* Why 64?
  63.        Indeed, we should align it:

libavutil/mem.c:91:5: 
  89.     ptr = malloc(size);
  90. #endif
  91.     return ptr;
          ^
  92. }
  93. 

libavutil/mem.c:92:1: return from a call to av_malloc
  90. #endif
  91.     return ptr;
  92. }
      ^
  93. 
  94. void *av_realloc(void *ptr, unsigned int size)

libavcodec/roqvideoenc.c:834:5: 
832.     uint8_t mb2[3*4];
833.     roq_cell *results4 = av_malloc(sizeof(roq_cell)*MAX_CBS_4x4*4);
834.     uint8_t *yuvClusters=av_malloc(sizeof(int)*max*6*4);
         ^
835.     int *points = av_malloc(max*6*4*sizeof(int));
836.     int bias;

libavutil/mem.c:42:1: start of procedure av_malloc()
  40.    linker will do it automatically */
  41. 
  42. void *av_malloc(unsigned int size)
      ^
  43. {
  44.     void *ptr;

libavutil/mem.c:50:8: Taking false branch
  48. 
  49.     /* let's disallow possible ambiguous cases */
  50.     if(size > (INT_MAX-16) )
             ^
  51.         return NULL;
  52. 

libavutil/mem.c:61:5: Skipping memalign(): method has no implementation
  59.     ((char*)ptr)[-1]= diff;
  60. #elif defined (HAVE_MEMALIGN)
  61.     ptr = memalign(16,size);
          ^
  62.     /* Why 64?
  63.        Indeed, we should align it:

libavutil/mem.c:91:5: 
  89.     ptr = malloc(size);
  90. #endif
  91.     return ptr;
          ^
  92. }
  93. 

libavutil/mem.c:92:1: return from a call to av_malloc
  90. #endif
  91.     return ptr;
  92. }
      ^
  93. 
  94. void *av_realloc(void *ptr, unsigned int size)

libavcodec/roqvideoenc.c:835:5: 
833.     roq_cell *results4 = av_malloc(sizeof(roq_cell)*MAX_CBS_4x4*4);
834.     uint8_t *yuvClusters=av_malloc(sizeof(int)*max*6*4);
835.     int *points = av_malloc(max*6*4*sizeof(int));
         ^
836.     int bias;
837. 

libavutil/mem.c:42:1: start of procedure av_malloc()
  40.    linker will do it automatically */
  41. 
  42. void *av_malloc(unsigned int size)
      ^
  43. {
  44.     void *ptr;

libavutil/mem.c:50:8: Taking true branch
  48. 
  49.     /* let's disallow possible ambiguous cases */
  50.     if(size > (INT_MAX-16) )
             ^
  51.         return NULL;
  52. 

libavutil/mem.c:51:9: 
  49.     /* let's disallow possible ambiguous cases */
  50.     if(size > (INT_MAX-16) )
  51.         return NULL;
              ^
  52. 
  53. #ifdef CONFIG_MEMALIGN_HACK

libavutil/mem.c:92:1: return from a call to av_malloc
  90. #endif
  91.     return ptr;
  92. }
      ^
  93. 
  94. void *av_realloc(void *ptr, unsigned int size)

libavcodec/roqvideoenc.c:839:5: 
837. 
838.     /* Subsample YUV data */
839.     create_clusters(enc->frame_to_enc, enc->width, enc->height, yuvClusters);
         ^
840. 
841.     /* Cast to integer and apply chroma bias */

libavcodec/roqvideoenc.c:778:1: start of procedure create_clusters()
  776.  * Creates YUV clusters for the entire image
  777.  */
  778. static void create_clusters(AVFrame *frame, int w, int h, uint8_t *yuvClusters)
       ^
  779. {
  780.     int i, j, k, l;

libavcodec/roqvideoenc.c:782:10: 
  780.     int i, j, k, l;
  781. 
  782.     for (i=0; i<h; i+=4)
                ^
  783.         for (j=0; j<w; j+=4) {
  784.             for (k=0; k < 2; k++)

libavcodec/roqvideoenc.c:782:15: Loop condition is false. Leaving loop
  780.     int i, j, k, l;
  781. 
  782.     for (i=0; i<h; i+=4)
                     ^
  783.         for (j=0; j<w; j+=4) {
  784.             for (k=0; k < 2; k++)

libavcodec/roqvideoenc.c:790:1: return from a call to create_clusters
  788.             yuvClusters += 24;
  789.         }
  790. }
       ^
  791. 
  792. static void generate_codebook(RoqContext *enc, roq_tempdata_t *tempdata,

libavcodec/roqvideoenc.c:842:10: 
840. 
841.     /* Cast to integer and apply chroma bias */
842.     for (i=0; i<max*24; i++) {
              ^
843.         bias = ((i%6)<4) ? 1 : CHROMA_BIAS;
844.         points[i] = bias*yuvClusters[i];

libavcodec/roqvideoenc.c:842:15: Loop condition is true. Entering loop body
840. 
841.     /* Cast to integer and apply chroma bias */
842.     for (i=0; i<max*24; i++) {
                   ^
843.         bias = ((i%6)<4) ? 1 : CHROMA_BIAS;
844.         points[i] = bias*yuvClusters[i];

libavcodec/roqvideoenc.c:843:17: Condition is true
841.     /* Cast to integer and apply chroma bias */
842.     for (i=0; i<max*24; i++) {
843.         bias = ((i%6)<4) ? 1 : CHROMA_BIAS;
                     ^
844.         points[i] = bias*yuvClusters[i];
845.     }

libavcodec/roqvideoenc.c:843:16: 
841.     /* Cast to integer and apply chroma bias */
842.     for (i=0; i<max*24; i++) {
843.         bias = ((i%6)<4) ? 1 : CHROMA_BIAS;
                    ^
844.         points[i] = bias*yuvClusters[i];
845.     }

libavcodec/roqvideoenc.c:843:9: 
841.     /* Cast to integer and apply chroma bias */
842.     for (i=0; i<max*24; i++) {
843.         bias = ((i%6)<4) ? 1 : CHROMA_BIAS;
             ^
844.         points[i] = bias*yuvClusters[i];
845.     }

libavcodec/roqvideoenc.c:844:9: 
842.     for (i=0; i<max*24; i++) {
843.         bias = ((i%6)<4) ? 1 : CHROMA_BIAS;
844.         points[i] = bias*yuvClusters[i];
             ^
845.     }
846. 

static void generate_new_codebooks(RoqContext *enc, roq_tempdata_t *tempData)
{
    int i,j;
    roq_codebooks_t *codebooks = &tempData->codebooks;
    int max = enc->width*enc->height/16;
    uint8_t mb2[3*4];
    roq_cell *results4 = av_malloc(sizeof(roq_cell)*MAX_CBS_4x4*4);
    uint8_t *yuvClusters=av_malloc(sizeof(int)*max*6*4);
    int *points = av_malloc(max*6*4*sizeof(int));
    int bias;
    create_clusters(enc->frame_to_enc, enc->width, enc->height, yuvClusters);
    for (i=0; i<max*24; i++) {
        bias = ((i%6)<4) ? 1 : CHROMA_BIAS;
        points[i] = bias*yuvClusters[i];
    }
    generate_codebook(enc, tempData, points, max, results4, 4, MAX_CBS_4x4);
    codebooks->numCB4 = MAX_CBS_4x4;
    tempData->closest_cb2 = av_malloc(max*4*sizeof(int));
    generate_codebook(enc, tempData, points, max*4, enc->cb2x2, 2, MAX_CBS_2x2);
    codebooks->numCB2 = MAX_CBS_2x2;
    for (i=0; i<codebooks->numCB2; i++)
        unpack_roq_cell(enc->cb2x2 + i, codebooks->unpacked_cb2 + i*2*2*3);
    for (i=0; i<codebooks->numCB4; i++) {
        for (j=0; j<4; j++) {
            unpack_roq_cell(&results4[4*i + j], mb2);
            index_mb(mb2, codebooks->unpacked_cb2, codebooks->numCB2,
                     &enc->cb4x4[i].idx[j], 2);
        }
        unpack_roq_qcell(codebooks->unpacked_cb2, enc->cb4x4 + i,
                         codebooks->unpacked_cb4 + i*4*4*3);
        enlarge_roq_mb4(codebooks->unpacked_cb4 + i*4*4*3,
                        codebooks->unpacked_cb4_enlarged + i*8*8*3);
    }
    av_free(yuvClusters);
    av_free(points);
    av_free(results4);
}
['static void generate_new_codebooks(RoqContext *enc, roq_tempdata_t *tempData)\n{\n    int i,j;\n    roq_codebooks_t *codebooks = &tempData->codebooks;\n    int max = enc->width*enc->height/16;\n    uint8_t mb2[3*4];\n    roq_cell *results4 = av_malloc(sizeof(roq_cell)*MAX_CBS_4x4*4);\n    uint8_t *yuvClusters=av_malloc(sizeof(int)*max*6*4);\n    int *points = av_malloc(max*6*4*sizeof(int));\n    int bias;\n    create_clusters(enc->frame_to_enc, enc->width, enc->height, yuvClusters);\n    for (i=0; i<max*24; i++) {\n        bias = ((i%6)<4) ? 1 : CHROMA_BIAS;\n        points[i] = bias*yuvClusters[i];\n    }\n    generate_codebook(enc, tempData, points, max, results4, 4, MAX_CBS_4x4);\n    codebooks->numCB4 = MAX_CBS_4x4;\n    tempData->closest_cb2 = av_malloc(max*4*sizeof(int));\n    generate_codebook(enc, tempData, points, max*4, enc->cb2x2, 2, MAX_CBS_2x2);\n    codebooks->numCB2 = MAX_CBS_2x2;\n    for (i=0; i<codebooks->numCB2; i++)\n        unpack_roq_cell(enc->cb2x2 + i, codebooks->unpacked_cb2 + i*2*2*3);\n    for (i=0; i<codebooks->numCB4; i++) {\n        for (j=0; j<4; j++) {\n            unpack_roq_cell(&results4[4*i + j], mb2);\n            index_mb(mb2, codebooks->unpacked_cb2, codebooks->numCB2,\n                     &enc->cb4x4[i].idx[j], 2);\n        }\n        unpack_roq_qcell(codebooks->unpacked_cb2, enc->cb4x4 + i,\n                         codebooks->unpacked_cb4 + i*4*4*3);\n        enlarge_roq_mb4(codebooks->unpacked_cb4 + i*4*4*3,\n                        codebooks->unpacked_cb4_enlarged + i*8*8*3);\n    }\n    av_free(yuvClusters);\n    av_free(points);\n    av_free(results4);\n}', 'void *av_malloc(unsigned int size)\n{\n    void *ptr;\n#ifdef CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#ifdef 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 defined (HAVE_MEMALIGN)\n    ptr = memalign(16,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}', 'static void create_clusters(AVFrame *frame, int w, int h, uint8_t *yuvClusters)\n{\n    int i, j, k, l;\n    for (i=0; i<h; i+=4)\n        for (j=0; j<w; j+=4) {\n            for (k=0; k < 2; k++)\n                for (l=0; l < 2; l++)\n                    frame_block_to_cell(yuvClusters + (l + 2*k)*6, frame->data,\n                                        i+2*k, j+2*l, frame->linesize);\n            yuvClusters += 24;\n        }\n}']