summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-11-29 11:55:34 +0000
committerRobin Watts <robin.watts@artifex.com>2012-11-29 11:57:11 +0000
commitc3fa0d45ff96eefe6effaeffc45516c6f85587bd (patch)
tree5f6b8682571b9a76ffde02895ce1b7fc109d9c95 /fitz
parent94b2a364223143dc7f749862c6983173d8b47a66 (diff)
downloadmupdf-c3fa0d45ff96eefe6effaeffc45516c6f85587bd.tar.xz
Bug 693463: Fix various memory leaks.
All these leaks were spotted by zeniko, so credit/thanks to him.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/base_xml.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/fitz/base_xml.c b/fitz/base_xml.c
index c8635f93..d715259b 100644
--- a/fitz/base_xml.c
+++ b/fitz/base_xml.c
@@ -434,12 +434,22 @@ fz_parse_xml(fz_context *ctx, unsigned char *s, int n)
p = convert_to_utf8(ctx, s, n);
- error = xml_parse_document_imp(&parser, p);
- if (error)
- fz_throw(ctx, "%s", error);
-
- if (p != (char*)s)
- fz_free(ctx, p);
+ fz_try(ctx)
+ {
+ error = xml_parse_document_imp(&parser, p);
+ if (error)
+ fz_throw(ctx, "%s", error);
+ }
+ fz_always(ctx)
+ {
+ if (p != (char*)s)
+ fz_free(ctx, p);
+ }
+ fz_catch(ctx)
+ {
+ fz_free_xml(ctx, root.down);
+ fz_rethrow(ctx);
+ }
return root.down;
}