diff options
author | Robin Watts <robin.watts@artifex.com> | 2011-12-16 16:38:04 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2011-12-16 16:38:04 +0000 |
commit | 0efd7871319442987ee68b199a1ad2404af09a90 (patch) | |
tree | 81e800166e6c2c1f05c7ffe3f29a98ad984a20ce | |
parent | 09a016ee7c5c81580b27db3bd193b38cb3bd4f0e (diff) | |
download | mupdf-0efd7871319442987ee68b199a1ad2404af09a90.tar.xz |
Mote memsqueezing fixes.
-rw-r--r-- | fitz/stm_open.c | 3 | ||||
-rw-r--r-- | pdf/pdf_interpret.c | 55 |
2 files changed, 34 insertions, 24 deletions
diff --git a/fitz/stm_open.c b/fitz/stm_open.c index dfb4ed8d..ae918667 100644 --- a/fitz/stm_open.c +++ b/fitz/stm_open.c @@ -153,7 +153,8 @@ fz_open_buffer(fz_context *ctx, fz_buffer *buf) { fz_stream *stm; - stm = fz_new_stream(ctx, fz_keep_buffer(buf), read_buffer, close_buffer); + stm = fz_new_stream(ctx, buf, read_buffer, close_buffer); + fz_keep_buffer(buf); stm->seek = seek_buffer; stm->bp = buf->data; diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c index 674cccc4..14d91d23 100644 --- a/pdf/pdf_interpret.c +++ b/pdf/pdf_interpret.c @@ -843,35 +843,44 @@ static pdf_csi * pdf_new_csi(pdf_xref *xref, fz_device *dev, fz_matrix ctm, char *event) { pdf_csi *csi; + fz_context *ctx = dev->ctx; - csi = fz_malloc_struct(dev->ctx, pdf_csi); - csi->xref = xref; - csi->dev = dev; - csi->event = event; + csi = fz_malloc_struct(ctx, pdf_csi); + fz_try(ctx) + { + csi->xref = xref; + csi->dev = dev; + csi->event = event; - csi->top = 0; - csi->obj = NULL; - csi->name[0] = 0; - csi->string_len = 0; - memset(csi->stack, 0, sizeof csi->stack); + csi->top = 0; + csi->obj = NULL; + csi->name[0] = 0; + csi->string_len = 0; + memset(csi->stack, 0, sizeof csi->stack); - csi->xbalance = 0; - csi->in_text = 0; - csi->in_hidden_ocg = 0; + csi->xbalance = 0; + csi->in_text = 0; + csi->in_hidden_ocg = 0; - csi->path = fz_new_path(xref->ctx); - csi->clip = 0; - csi->clip_even_odd = 0; + csi->path = fz_new_path(ctx); + csi->clip = 0; + csi->clip_even_odd = 0; - csi->text = NULL; - csi->tlm = fz_identity; - csi->tm = fz_identity; - csi->text_mode = 0; - csi->accumulate = 1; + csi->text = NULL; + csi->tlm = fz_identity; + csi->tm = fz_identity; + csi->text_mode = 0; + csi->accumulate = 1; - csi->top_ctm = ctm; - pdf_init_gstate(&csi->gstate[0], ctm); - csi->gtop = 0; + csi->top_ctm = ctm; + pdf_init_gstate(&csi->gstate[0], ctm); + csi->gtop = 0; + } + fz_catch(ctx) + { + fz_free(ctx, csi); + fz_rethrow(ctx); + } return csi; } |