fix memleakintidyParseBuffer

This commit is contained in:
yu_boyun 2020-11-26 10:51:54 +08:00
parent 9cd53dc3d3
commit cd8790a640
2 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,27 @@
From 8f0e7aa22a854add9e6082ca5136e82f032a236a Mon Sep 17 00:00:00 2001
From: lutianxiong <lutianxiong@huawei.com>
Date: Sun, 22 Nov 2020 00:10:12 +0800
Subject: [PATCH] Free attributes before return NULL (#899)
---
src/lexer.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/lexer.c b/src/lexer.c
index 49b74f5..16a8fef 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -3469,6 +3469,10 @@ static Node* GetTokenFromStream( TidyDocImpl* doc, GetTokenMode mode )
return node; /* the COMMENT token */
}
+ /* check attributes before return NULL */
+ if (attributes)
+ TY_(FreeAttribute)( doc, attributes );
+
DEBUG_LOG(SPRTF("Returning NULL...\n"));
return NULL;
}
--
1.8.3.1

View File

@ -3,7 +3,7 @@
Name: tidy Name: tidy
Version: 5.6.0 Version: 5.6.0
Release: 3 Release: 4
Summary: Utility to clean up and pretty print HTML/XHTML/XML Summary: Utility to clean up and pretty print HTML/XHTML/XML
License: W3C License: W3C
URL: http://www.html-tidy.org/ URL: http://www.html-tidy.org/
@ -11,6 +11,7 @@ Source0: https://github.com/htacg/%{upname}/archive/%{version}.tar.gz#/%{u
Patch0001: 0002-Issue-656-protect-against-NULL-node-set-in-loop.patch Patch0001: 0002-Issue-656-protect-against-NULL-node-set-in-loop.patch
Patch0002: fix-memleak-in-GetTokenFromStream.patch Patch0002: fix-memleak-in-GetTokenFromStream.patch
Patch0003: free-attributes-before-return-NULL.patch
BuildRequires: gcc-c++ cmake gcc libxslt pkgconfig BuildRequires: gcc-c++ cmake gcc libxslt pkgconfig
Provides: tidy-html5 = %{version}-%{release} Provides: tidy-html5 = %{version}-%{release}
@ -81,6 +82,12 @@ ln -s tidyplatform.h $RPM_BUILD_ROOT%{_includedir}/platform.h
%{_mandir}/* %{_mandir}/*
%changelog %changelog
* Thu Nov 26 2020 yuboyun <yuboyun@huawei.com> - 5.6.0-4
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix memleak in tidyParseBuffer
* Fri Nov 20 2020 lunankun <lunankun@huawei.com> - 5.6.0-3 * Fri Nov 20 2020 lunankun <lunankun@huawei.com> - 5.6.0-3
- Type:bugfix - Type:bugfix
- ID:NA - ID:NA