From c3fa0d45ff96eefe6effaeffc45516c6f85587bd Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 29 Nov 2012 11:55:34 +0000 Subject: Bug 693463: Fix various memory leaks. All these leaks were spotted by zeniko, so credit/thanks to him. --- fitz/base_xml.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'fitz') 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; } -- cgit v1.2.3