From 3585d4c31ad6b0c0bd058cf9d94193f4d243b8c6 Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Thu, 19 Mar 2015 19:14:27 +0100 Subject: [PATCH] Issue #186 - Move FreeLexer() to near last --- src/tidylib.c | 13 ++++++++++--- version.txt | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/tidylib.c b/src/tidylib.c index d369362..5d61478 100755 --- a/src/tidylib.c +++ b/src/tidylib.c @@ -171,7 +171,6 @@ void tidyDocRelease( TidyDocImpl* doc ) doc->errout = NULL; TY_(FreePrintBuf)( doc ); - TY_(FreeLexer)( doc ); TY_(FreeNode)(doc, &doc->root); TidyClearMemory(&doc->root, sizeof(Node)); @@ -181,6 +180,11 @@ void tidyDocRelease( TidyDocImpl* doc ) TY_(FreeConfig)( doc ); TY_(FreeAttrTable)( doc ); TY_(FreeTags)( doc ); + /*\ + * Issue #186 - Now FreeNode depend on the doctype, so the lexer is needed + * to determine which hash is to be used, so free it last. + \*/ + TY_(FreeLexer)( doc ); TidyDocFree( doc, doc ); } } @@ -1182,7 +1186,6 @@ int TY_(DocParseStream)( TidyDocImpl* doc, StreamIn* in ) doc->docIn = in; TY_(TakeConfigSnapshot)( doc ); /* Save config state */ - TY_(FreeLexer)( doc ); TY_(FreeAnchors)( doc ); TY_(FreeNode)(doc, &doc->root); @@ -1190,7 +1193,11 @@ int TY_(DocParseStream)( TidyDocImpl* doc, StreamIn* in ) if (doc->givenDoctype) TidyDocFree(doc, doc->givenDoctype); - + /*\ + * Issue #186 - Now FreeNode depend on the doctype, so the lexer is needed + * to determine which hash is to be used, so free it last. + \*/ + TY_(FreeLexer)( doc ); doc->givenDoctype = NULL; doc->lexer = TY_(NewLexer)( doc ); diff --git a/version.txt b/version.txt index 422431d..bfcd505 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -4.9.22 \ No newline at end of file +4.9.23 \ No newline at end of file