!112 fix valgrind errors in xmlParseBalancedChunkMemoryRecover
From: @fly_fzc Reviewed-by: @xiezhipeng1 Signed-off-by: @xiezhipeng1
This commit is contained in:
commit
6d825831b1
@ -0,0 +1,30 @@
|
||||
From a0a8059b2cadaf6bb65469ead748873c61a17ace Mon Sep 17 00:00:00 2001
|
||||
From: Nick Wellnhofer <wellnhofer@aevum.de>
|
||||
Date: Sat, 30 May 2020 15:33:03 +0200
|
||||
Subject: [PATCH] Revert "Fix memory leak in
|
||||
xmlParseBalancedChunkMemoryRecover"
|
||||
|
||||
This reverts commit 5a02583c7e683896d84878bd90641d8d9b0d0549.
|
||||
|
||||
Fixes #161.
|
||||
---
|
||||
parser.c | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/parser.c b/parser.c
|
||||
index 4ea8e84..4cc58b1 100644
|
||||
--- a/parser.c
|
||||
+++ b/parser.c
|
||||
@@ -13785,8 +13785,7 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
newDoc->intSubset = NULL;
|
||||
newDoc->extSubset = NULL;
|
||||
- if(doc != NULL)
|
||||
- newDoc->oldNs = NULL;
|
||||
+ newDoc->oldNs = NULL;
|
||||
xmlFreeDoc(newDoc);
|
||||
|
||||
return(ret);
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -0,0 +1,60 @@
|
||||
From 2e8cc66d8fbf573e48a37382bf354dfdbc20ef08 Mon Sep 17 00:00:00 2001
|
||||
From: Nick Wellnhofer <wellnhofer@aevum.de>
|
||||
Date: Sat, 30 May 2020 15:40:08 +0200
|
||||
Subject: [PATCH] xmlParseBalancedChunkMemory must not be called with NULL doc
|
||||
|
||||
There is no way to avoid memory leaks without a document to hold the
|
||||
namespace list.
|
||||
---
|
||||
parser.c | 7 +++++--
|
||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/parser.c b/parser.c
|
||||
index 4cc58b1..046f1ce 100644
|
||||
--- a/parser.c
|
||||
+++ b/parser.c
|
||||
@@ -13176,7 +13176,7 @@ xmlParseExternalEntity(xmlDocPtr doc, xmlSAXHandlerPtr sax, void *user_data,
|
||||
|
||||
/**
|
||||
* xmlParseBalancedChunkMemory:
|
||||
- * @doc: the document the chunk pertains to
|
||||
+ * @doc: the document the chunk pertains to (must not be NULL)
|
||||
* @sax: the SAX handler bloc (possibly NULL)
|
||||
* @user_data: The user data returned on SAX callbacks (possibly NULL)
|
||||
* @depth: Used for loop detection, use 0
|
||||
@@ -13628,7 +13628,7 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
/**
|
||||
* xmlParseBalancedChunkMemoryRecover:
|
||||
- * @doc: the document the chunk pertains to
|
||||
+ * @doc: the document the chunk pertains to (must not be NULL)
|
||||
* @sax: the SAX handler bloc (possibly NULL)
|
||||
* @user_data: The user data returned on SAX callbacks (possibly NULL)
|
||||
* @depth: Used for loop detection, use 0
|
||||
@@ -13700,6 +13700,7 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
|
||||
} else {
|
||||
xmlCtxtUseOptionsInternal(ctxt, XML_PARSE_NODICT, NULL);
|
||||
}
|
||||
+ /* doc == NULL is only supported for historic reasons */
|
||||
if (doc != NULL) {
|
||||
newDoc->intSubset = doc->intSubset;
|
||||
newDoc->extSubset = doc->extSubset;
|
||||
@@ -13716,6 +13717,7 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
|
||||
}
|
||||
xmlAddChild((xmlNodePtr) newDoc, newRoot);
|
||||
nodePush(ctxt, newRoot);
|
||||
+ /* doc == NULL is only supported for historic reasons */
|
||||
if (doc == NULL) {
|
||||
ctxt->myDoc = newDoc;
|
||||
} else {
|
||||
@@ -13785,6 +13787,7 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
newDoc->intSubset = NULL;
|
||||
newDoc->extSubset = NULL;
|
||||
+ /* This leaks the namespace list if doc == NULL */
|
||||
newDoc->oldNs = NULL;
|
||||
xmlFreeDoc(newDoc);
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Summary: Library providing XML and HTML support
|
||||
Name: libxml2
|
||||
Version: 2.9.10
|
||||
Release: 25
|
||||
Release: 26
|
||||
License: MIT
|
||||
Group: Development/Libraries
|
||||
Source: ftp://xmlsoft.org/libxml2/libxml2-%{version}.tar.gz
|
||||
@ -116,6 +116,8 @@ Patch103:Handle-dumps-of-corrupted-documents-more-gracefully.patch
|
||||
Patch104:Remove-unused-encoding-parameter-of-HTML-output-func.patch
|
||||
Patch105:Work-around-lxml-API-abuse.patch
|
||||
Patch106:Fix-regression-in-xmlNodeDumpOutputInternal.patch
|
||||
Patch107:backport-Revert-Fix-memory-leak-in-xmlParseBalancedChunkMemor.patch
|
||||
Patch108:backport-xmlParseBalancedChunkMemory-must-not-be-called-with-.patch
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-root
|
||||
BuildRequires: python2-devel
|
||||
@ -308,6 +310,9 @@ rm -fr %{buildroot}
|
||||
|
||||
|
||||
%changelog
|
||||
* Sat Feb 26 2022 fuanan <fuanan3@h-partners.com> - 2.9.10-26
|
||||
- fix valgrind errors in xmlParseBalancedChunkMemoryRecover
|
||||
|
||||
* Sat Feb 12 2022 fuanan <fuanan3@h-partners.com> - 2.9.10-25
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user