libavcodec/dvbsubdec.c:1286: error: Null Dereference
  pointer `sub->rects` last assigned on line 1269 could be null and is dereferenced at line 1286, column 16.

libavcodec/dvbsubdec.c:1257:1: start of procedure dvbsub_display_end_segment()
1255. #endif
1256. 
1257. static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf,
      ^
1258.                                         int buf_size, AVSubtitle *sub)
1259. {

libavcodec/dvbsubdec.c:1260:5: 
1258.                                         int buf_size, AVSubtitle *sub)
1259. {
1260.     DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;
          ^
1261. 
1262.     DVBSubRegion *region;

libavcodec/dvbsubdec.c:1269:5: 
1267.     int i;
1268. 
1269.     sub->rects = NULL;
          ^
1270.     sub->start_display_time = 0;
1271.     sub->end_display_time = ctx->time_out * 1000;

libavcodec/dvbsubdec.c:1270:5: 
1268. 
1269.     sub->rects = NULL;
1270.     sub->start_display_time = 0;
          ^
1271.     sub->end_display_time = ctx->time_out * 1000;
1272.     sub->format = 0;

libavcodec/dvbsubdec.c:1271:5: 
1269.     sub->rects = NULL;
1270.     sub->start_display_time = 0;
1271.     sub->end_display_time = ctx->time_out * 1000;
          ^
1272.     sub->format = 0;
1273. 

libavcodec/dvbsubdec.c:1272:5: 
1270.     sub->start_display_time = 0;
1271.     sub->end_display_time = ctx->time_out * 1000;
1272.     sub->format = 0;
          ^
1273. 
1274.     sub->num_rects = ctx->display_list_size;

libavcodec/dvbsubdec.c:1274:5: 
1272.     sub->format = 0;
1273. 
1274.     sub->num_rects = ctx->display_list_size;
          ^
1275. 
1276.     if (sub->num_rects > 0){

libavcodec/dvbsubdec.c:1276:9: Taking false branch
1274.     sub->num_rects = ctx->display_list_size;
1275. 
1276.     if (sub->num_rects > 0){
              ^
1277.         sub->rects = av_mallocz(sizeof(*sub->rects) * sub->num_rects);
1278.         for(i=0; i<sub->num_rects; i++)

libavcodec/dvbsubdec.c:1282:5: 
1280.     }
1281. 
1282.     i = 0;
          ^
1283. 
1284.     for (display = ctx->display_list; display; display = display->next) {

libavcodec/dvbsubdec.c:1284:10: 
1282.     i = 0;
1283. 
1284.     for (display = ctx->display_list; display; display = display->next) {
               ^
1285.         region = get_region(ctx, display->region_id);
1286.         rect = sub->rects[i];

libavcodec/dvbsubdec.c:1284:39: Loop condition is true. Entering loop body
1282.     i = 0;
1283. 
1284.     for (display = ctx->display_list; display; display = display->next) {
                                            ^
1285.         region = get_region(ctx, display->region_id);
1286.         rect = sub->rects[i];

libavcodec/dvbsubdec.c:1285:9: 
1283. 
1284.     for (display = ctx->display_list; display; display = display->next) {
1285.         region = get_region(ctx, display->region_id);
              ^
1286.         rect = sub->rects[i];
1287. 

libavcodec/dvbsubdec.c:255:1: start of procedure get_region()
  253. }
  254. 
  255. static DVBSubRegion* get_region(DVBSubContext *ctx, int region_id)
       ^
  256. {
  257.     DVBSubRegion *ptr = ctx->region_list;

libavcodec/dvbsubdec.c:257:5: 
  255. static DVBSubRegion* get_region(DVBSubContext *ctx, int region_id)
  256. {
  257.     DVBSubRegion *ptr = ctx->region_list;
           ^
  258. 
  259.     while (ptr && ptr->id != region_id) {

libavcodec/dvbsubdec.c:259:12: Loop condition is true. Entering loop body
  257.     DVBSubRegion *ptr = ctx->region_list;
  258. 
  259.     while (ptr && ptr->id != region_id) {
                  ^
  260.         ptr = ptr->next;
  261.     }

libavcodec/dvbsubdec.c:259:19: Loop condition is true. Entering loop body
  257.     DVBSubRegion *ptr = ctx->region_list;
  258. 
  259.     while (ptr && ptr->id != region_id) {
                         ^
  260.         ptr = ptr->next;
  261.     }

libavcodec/dvbsubdec.c:260:9: 
  258. 
  259.     while (ptr && ptr->id != region_id) {
  260.         ptr = ptr->next;
               ^
  261.     }
  262. 

libavcodec/dvbsubdec.c:259:12: Loop condition is true. Entering loop body
  257.     DVBSubRegion *ptr = ctx->region_list;
  258. 
  259.     while (ptr && ptr->id != region_id) {
                  ^
  260.         ptr = ptr->next;
  261.     }

libavcodec/dvbsubdec.c:259:19: Loop condition is true. Entering loop body
  257.     DVBSubRegion *ptr = ctx->region_list;
  258. 
  259.     while (ptr && ptr->id != region_id) {
                         ^
  260.         ptr = ptr->next;
  261.     }

libavcodec/dvbsubdec.c:260:9: 
  258. 
  259.     while (ptr && ptr->id != region_id) {
  260.         ptr = ptr->next;
               ^
  261.     }
  262. 

libavcodec/dvbsubdec.c:259:12: Loop condition is true. Entering loop body
  257.     DVBSubRegion *ptr = ctx->region_list;
  258. 
  259.     while (ptr && ptr->id != region_id) {
                  ^
  260.         ptr = ptr->next;
  261.     }

libavcodec/dvbsubdec.c:259:19: Loop condition is false. Leaving loop
  257.     DVBSubRegion *ptr = ctx->region_list;
  258. 
  259.     while (ptr && ptr->id != region_id) {
                         ^
  260.         ptr = ptr->next;
  261.     }

libavcodec/dvbsubdec.c:263:5: 
  261.     }
  262. 
  263.     return ptr;
           ^
  264. }
  265. 

libavcodec/dvbsubdec.c:264:1: return from a call to get_region
  262. 
  263.     return ptr;
  264. }
       ^
  265. 
  266. static void delete_region_display_list(DVBSubContext *ctx, DVBSubRegion *region)

libavcodec/dvbsubdec.c:1286:9: 
1284.     for (display = ctx->display_list; display; display = display->next) {
1285.         region = get_region(ctx, display->region_id);
1286.         rect = sub->rects[i];
              ^
1287. 
1288.         if (!region)

static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf,
                                        int buf_size, AVSubtitle *sub)
{
    DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;
    DVBSubRegion *region;
    DVBSubRegionDisplay *display;
    AVSubtitleRect *rect;
    DVBSubCLUT *clut;
    uint32_t *clut_table;
    int i;
    sub->rects = NULL;
    sub->start_display_time = 0;
    sub->end_display_time = ctx->time_out * 1000;
    sub->format = 0;
    sub->num_rects = ctx->display_list_size;
    if (sub->num_rects > 0){
        sub->rects = av_mallocz(sizeof(*sub->rects) * sub->num_rects);
        for(i=0; i<sub->num_rects; i++)
            sub->rects[i] = av_mallocz(sizeof(*sub->rects[i]));
    }
    i = 0;
    for (display = ctx->display_list; display; display = display->next) {
        region = get_region(ctx, display->region_id);
        rect = sub->rects[i];
        if (!region)
            continue;
        rect->x = display->x_pos;
        rect->y = display->y_pos;
        rect->w = region->width;
        rect->h = region->height;
        rect->nb_colors = 16;
        rect->type      = SUBTITLE_BITMAP;
        rect->pict.linesize[0] = region->width;
        clut = get_clut(ctx, region->clut);
        if (!clut)
            clut = &default_clut;
        switch (region->depth) {
        case 2:
            clut_table = clut->clut4;
            break;
        case 8:
            clut_table = clut->clut256;
            break;
        case 4:
        default:
            clut_table = clut->clut16;
            break;
        }
        rect->pict.data[1] = av_malloc((1 << region->depth) * sizeof(uint32_t));
        memcpy(rect->pict.data[1], clut_table, (1 << region->depth) * sizeof(uint32_t));
        rect->pict.data[0] = av_malloc(region->buf_size);
        memcpy(rect->pict.data[0], region->pbuf, region->buf_size);
        i++;
    }
    sub->num_rects = i;
#ifdef DEBUG_SAVE_IMAGES
    save_display_set(ctx);
#endif
    return 1;
}
['static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf,\n                                        int buf_size, AVSubtitle *sub)\n{\n    DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;\n    DVBSubRegion *region;\n    DVBSubRegionDisplay *display;\n    AVSubtitleRect *rect;\n    DVBSubCLUT *clut;\n    uint32_t *clut_table;\n    int i;\n    sub->rects = NULL;\n    sub->start_display_time = 0;\n    sub->end_display_time = ctx->time_out * 1000;\n    sub->format = 0;\n    sub->num_rects = ctx->display_list_size;\n    if (sub->num_rects > 0){\n        sub->rects = av_mallocz(sizeof(*sub->rects) * sub->num_rects);\n        for(i=0; i<sub->num_rects; i++)\n            sub->rects[i] = av_mallocz(sizeof(*sub->rects[i]));\n    }\n    i = 0;\n    for (display = ctx->display_list; display; display = display->next) {\n        region = get_region(ctx, display->region_id);\n        rect = sub->rects[i];\n        if (!region)\n            continue;\n        rect->x = display->x_pos;\n        rect->y = display->y_pos;\n        rect->w = region->width;\n        rect->h = region->height;\n        rect->nb_colors = 16;\n        rect->type      = SUBTITLE_BITMAP;\n        rect->pict.linesize[0] = region->width;\n        clut = get_clut(ctx, region->clut);\n        if (!clut)\n            clut = &default_clut;\n        switch (region->depth) {\n        case 2:\n            clut_table = clut->clut4;\n            break;\n        case 8:\n            clut_table = clut->clut256;\n            break;\n        case 4:\n        default:\n            clut_table = clut->clut16;\n            break;\n        }\n        rect->pict.data[1] = av_malloc((1 << region->depth) * sizeof(uint32_t));\n        memcpy(rect->pict.data[1], clut_table, (1 << region->depth) * sizeof(uint32_t));\n        rect->pict.data[0] = av_malloc(region->buf_size);\n        memcpy(rect->pict.data[0], region->pbuf, region->buf_size);\n        i++;\n    }\n    sub->num_rects = i;\n#ifdef DEBUG_SAVE_IMAGES\n    save_display_set(ctx);\n#endif\n    return 1;\n}', 'static DVBSubRegion* get_region(DVBSubContext *ctx, int region_id)\n{\n    DVBSubRegion *ptr = ctx->region_list;\n    while (ptr && ptr->id != region_id) {\n        ptr = ptr->next;\n    }\n    return ptr;\n}']