Skip to content

Commit a894a26

Browse files
committed
Bug 701034: Wait for the correct number of band workers.
Previously the code starting the workers was bounded to the number of bands left to process, but the code waiting for the band workers to finish and clean up the resources was not bounded. This caused a double free of a pixmap belonging to a stale worker.
1 parent 08d2719 commit a894a26

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

source/tools/muraster.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -574,24 +574,23 @@ static int dodrawpage(fz_context *ctx, int pagenum, fz_cookie *cookie, render_de
574574
fz_pixmap *pix = NULL;
575575
fz_bitmap *bit = NULL;
576576
int errors_are_fatal = 0;
577+
fz_irect ibounds = render->ibounds;
578+
fz_rect tbounds = render->tbounds;
579+
int total_height = ibounds.y1 - ibounds.y0;
580+
int start_offset = min_band_height * render->bands_rendered;
581+
int remaining_start = ibounds.y0 + start_offset;
582+
int remaining_height = ibounds.y1 - remaining_start;
583+
int band_height = min_band_height * render->band_height_multiple;
584+
int bands = (remaining_height + band_height-1) / band_height;
585+
fz_matrix ctm = render->ctm;
586+
int band;
577587

578588
fz_var(pix);
579589
fz_var(bit);
580590
fz_var(errors_are_fatal);
581591

582592
fz_try(ctx)
583593
{
584-
fz_irect ibounds = render->ibounds;
585-
fz_rect tbounds = render->tbounds;
586-
int total_height = ibounds.y1 - ibounds.y0;
587-
int start_offset = min_band_height * render->bands_rendered;
588-
int remaining_start = ibounds.y0 + start_offset;
589-
int remaining_height = ibounds.y1 - remaining_start;
590-
int band_height = min_band_height * render->band_height_multiple;
591-
int bands = (remaining_height + band_height-1) / band_height;
592-
fz_matrix ctm = render->ctm;
593-
int band;
594-
595594
/* Set up ibounds and tbounds for a single band_height band.
596595
* We will adjust ctm as we go. */
597596
ibounds.y1 = ibounds.y0 + band_height;
@@ -688,7 +687,7 @@ static int dodrawpage(fz_context *ctx, int pagenum, fz_cookie *cookie, render_de
688687
if (render->num_workers > 0)
689688
{
690689
int band;
691-
for (band = 0; band < render->num_workers; band++)
690+
for (band = 0; band < fz_mini(render->num_workers, bands); band++)
692691
{
693692
worker_t *w = &workers[band];
694693
w->cookie.abort = 1;

0 commit comments

Comments
 (0)