加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
backport-malloc-fail-Fix-memory-leak-in-htmlCreateMemoryParserCtxt.patch 935 Bytes
一键复制 编辑 原始数据 按行查看 历史
冉召宇 提交于 2024-04-25 19:13 . libxml2切openEuler7.0
From fc256953d29698ba5918c32d14fc69ea69d7e64e Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Thu, 16 Feb 2023 14:47:41 +0100
Subject: [PATCH] malloc-fail: Fix memory leak in htmlCreateMemoryParserCtxt
Found with libFuzzer, see #344.
Reference:https://github.com/GNOME/libxml2/commit/fc256953d29698ba5918c32d14fc69ea69d7e64e
Conflict:NA
---
HTMLparser.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/HTMLparser.c b/HTMLparser.c
index 0ccd6e8..7ea2e62 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -5191,7 +5191,10 @@ htmlCreateMemoryParserCtxt(const char *buffer, int size) {
return(NULL);
buf = xmlParserInputBufferCreateMem(buffer, size, XML_CHAR_ENCODING_NONE);
- if (buf == NULL) return(NULL);
+ if (buf == NULL) {
+ xmlFreeParserCtxt(ctxt);
+ return(NULL);
+ }
input = xmlNewInputStream(ctxt);
if (input == NULL) {
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化