diff options
Diffstat (limited to 'pdf')
-rw-r--r-- | pdf/pdf_interpret.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c index 0976912e..0cfcdfae 100644 --- a/pdf/pdf_interpret.c +++ b/pdf/pdf_interpret.c @@ -95,7 +95,8 @@ struct pdf_csi_s /* graphics state */ fz_matrix top_ctm; - pdf_gstate gstate[64]; + pdf_gstate *gstate; + int gcap; int gtop; /* cookie support */ @@ -890,6 +891,9 @@ pdf_new_csi(pdf_xref *xref, fz_device *dev, fz_matrix ctm, char *event, fz_cooki csi->text_mode = 0; csi->accumulate = 1; + csi->gcap = 64; + csi->gstate = fz_malloc_array(ctx, csi->gcap, sizeof(pdf_gstate)); + csi->top_ctm = ctm; pdf_init_gstate(&csi->gstate[0], ctm); csi->gtop = 0; @@ -898,6 +902,7 @@ pdf_new_csi(pdf_xref *xref, fz_device *dev, fz_matrix ctm, char *event, fz_cooki } fz_catch(ctx) { + fz_free_path(ctx, csi->path); fz_free(ctx, csi); fz_rethrow(ctx); } @@ -950,13 +955,14 @@ static void pdf_gsave(pdf_csi *csi) { fz_context *ctx = csi->dev->ctx; - pdf_gstate *gs = csi->gstate + csi->gtop; + pdf_gstate *gs; - if (csi->gtop == nelem(csi->gstate) - 1) + if (csi->gtop == csi->gcap-1) { - fz_warn(ctx, "gstate overflow in content stream"); - return; + csi->gstate = fz_resize_array(ctx, csi->gstate, csi->gcap*2, sizeof(pdf_gstate)); + csi->gcap *= 2; } + gs = csi->gstate + csi->gtop; memcpy(&csi->gstate[csi->gtop + 1], &csi->gstate[csi->gtop], sizeof(pdf_gstate)); @@ -1030,6 +1036,8 @@ pdf_free_csi(pdf_csi *csi) pdf_clear_stack(csi); + fz_free(ctx, csi->gstate); + fz_free(ctx, csi); } |