if (sub->num_rects == 0) return 0;  sub->rects = av_mallocz(sizeof(AVSubtitleRect) * sub->num_rects);
if (sub->num_rects > 0) sub->rects = av_mallocz(sizeof(AVSubtitleRect) * sub->num_rects);
static int dvbsub_display_end_segment(AVCodecContext *avctx, 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)        return 0;        sub->rects = av_mallocz(sizeof(AVSubtitleRect) * sub->num_rects);    i = 0;    for (display = ctx->display_list; display != NULL; display = display->next) {        region = get_region(ctx, display->region_id);        rect = &sub->rects[i];                if (region == NULL)            continue;                rect->x = display->x_pos;        rect->y = display->y_pos;        rect->w = region->width;        rect->h = region->height;        rect->nb_colors = 16;        rect->linesize = region->width;        clut = get_clut(ctx, region->clut);                if (clut == NULL)            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->rgba_palette = av_malloc((1 << region->depth) * sizeof(uint32_t));        memcpy(rect->rgba_palette, clut_table, (1 << region->depth) * sizeof(uint32_t));                rect->bitmap = av_malloc(region->buf_size);        memcpy(rect->bitmap, region->pbuf, region->buf_size);                i++;    }        sub->num_rects = i;    #ifdef DEBUG_SAVE_IMAGES    save_display_set(ctx);#endif        return 1;}