diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-01-06 11:56:46 +0000 |
---|---|---|
committer | Robin Watts <robin@ghostscript.com> | 2012-01-06 13:49:24 +0000 |
commit | 8c0b958c8cd04eae8a65803db700240123fd38be (patch) | |
tree | 96c330707d07b24c6095b421e5a2ddb0d413348b /pdf/pdf_parse.c | |
parent | 09f1a3d3d863099c103100ed10c8cec82ea7aed3 (diff) | |
download | mupdf-8c0b958c8cd04eae8a65803db700240123fd38be.tar.xz |
Various memory leak fixes.
In error cases, ensure we free objects correctly. Thanks to Zeniko
for finding the problems (and many of the solutions!)
Diffstat (limited to 'pdf/pdf_parse.c')
-rw-r--r-- | pdf/pdf_parse.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/pdf/pdf_parse.c b/pdf/pdf_parse.c index 4b658d08..b2f4fbf7 100644 --- a/pdf/pdf_parse.c +++ b/pdf/pdf_parse.c @@ -42,7 +42,7 @@ pdf_to_utf8(fz_context *ctx, fz_obj *src) if (srclen >= 2 && srcptr[0] == 254 && srcptr[1] == 255) { - for (i = 2; i < srclen; i += 2) + for (i = 2; i + 1 < srclen; i += 2) { ucs = srcptr[i] << 8 | srcptr[i+1]; dstlen += runelen(ucs); @@ -50,7 +50,7 @@ pdf_to_utf8(fz_context *ctx, fz_obj *src) dstptr = dst = fz_malloc(ctx, dstlen + 1); - for (i = 2; i < srclen; i += 2) + for (i = 2; i + 1 < srclen; i += 2) { ucs = srcptr[i] << 8 | srcptr[i+1]; dstptr += runetochar(dstptr, &ucs); @@ -393,8 +393,6 @@ pdf_parse_dict(pdf_xref *xref, fz_stream *file, char *buf, int cap) fz_throw(ctx, "invalid indirect reference in dict"); default: - fz_drop_obj(key); - fz_drop_obj(dict); fz_throw(ctx, "unknown token in dict"); } |