From 0136474e1889014ecdeae5784b993d9e175ce636 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Wed, 10 Oct 2018 10:56:26 +0200 Subject: [PATCH] Fix memory leak caused by circular references in XML::XPath --- lib/WebService/Validator/HTML/W3C.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/WebService/Validator/HTML/W3C.pm b/lib/WebService/Validator/HTML/W3C.pm index d9c4369..dca14c9 100644 --- a/lib/WebService/Validator/HTML/W3C.pm +++ b/lib/WebService/Validator/HTML/W3C.pm @@ -325,6 +325,7 @@ sub errors { return undef; } + local $XML::XPath::SafeMode = 1; # avoid memory leaks my $xp = XML::XPath->new( xml => $self->_content() ); if ( $self->_output eq 'xml' ) { @@ -365,6 +366,8 @@ sub errors { } } + $xp->cleanup; + return \@errs; }