Skip to content

Commit

Permalink
Bug 702253: Avoid a use-after-free in fz_drop_band_writer
Browse files Browse the repository at this point in the history
A use-after-free would occur when a valid page was followed by
a page with invalid pixmap dimensions, causing bander --
a static -- to point to previously freed memory instead of a new
band_writer.
  • Loading branch information
theshoals authored and ccxvii committed May 5, 2020
1 parent 041267a commit 96751b2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions source/tools/mudraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,14 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
fz_always(ctx)
{
if (output_format != OUT_PCLM)
{
fz_drop_band_writer(ctx, bander);
/* bander must be set to NULL to avoid use-after-frees. A use-after-free
* would occur when a valid page was followed by a page with invalid
* pixmap dimensions, causing bander -- a static -- to point to previously
* freed memory instead of a new band_writer. */
bander = NULL;
}
fz_drop_bitmap(ctx, bit);
bit = NULL;
if (num_workers > 0)
Expand Down

0 comments on commit 96751b2

Please sign in to comment.