0 Star 0 Fork 13

openeuler-embedded/libtasn1

forked from src-openEuler/libtasn1 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
fix-memleaks-in-asn1-arrat2tree.patch 2.45 KB
一键复制 编辑 原始数据 按行查看 历史
杨壮壮 提交于 2020-08-27 15:40 . [LTS]update version to 4.16.0
From ea0e4fc2567edfc0d20141025837e2bd9c64c0cb Mon Sep 17 00:00:00 2001
From: opneErler BUildteam <[email protected]>
Date: Fri, 5 Jun 2020 15:46:37 +0800
Subject: [PATCH] fix memleaks in asn1 arrat2tree
---
lib/parser_aux.c | 2 +-
lib/structure.c | 20 +++++++++----
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/lib/parser_aux.c b/lib/parser_aux.c
index d5dbbf8..071f1be 100644
--- a/lib/parser_aux.c
+++ b/lib/parser_aux.c
@@ -767,7 +767,7 @@ _asn1_expand_object_id (list_type **list, asn1_node node)
return ASN1_ELEMENT_NOT_FOUND;
_asn1_set_down (p, p2->right);
- if (p2->down)
+ while (p2->down)
_asn1_delete_structure (*list, &p2->down, 0);
_asn1_delete_node_from_list(*list, p2);
_asn1_remove_node (p2, 0);
diff --git a/lib/structure.c b/lib/structure.c
index 8189c56..6dfba58 100644
--- a/lib/structure.c
+++ b/lib/structure.c
@@ -207,13 +207,13 @@ asn1_array2tree (const asn1_static_node * array, asn1_node * definitions,
if (move == DOWN)
{
- if (p_last && p_last->down)
+ while (p_last && p_last->down)
_asn1_delete_structure (e_list, &p_last->down, 0);
_asn1_set_down (p_last, p);
}
else if (move == RIGHT)
{
- if (p_last && p_last->right)
+ while (p_last && p_last->right)
_asn1_delete_structure (e_list, &p_last->right, 0);
_asn1_set_right (p_last, p);
}
@@ -317,7 +317,7 @@ int
_asn1_delete_structure (list_type *e_list, asn1_node * structure, unsigned int flags)
{
asn1_node p, p2, p3;
-
+ int flag_t = 1;
if (*structure == NULL)
return ASN1_ELEMENT_NOT_FOUND;
@@ -347,7 +347,11 @@ _asn1_delete_structure (list_type *e_list, asn1_node * structure, unsigned int f
{
p3 = _asn1_find_up (p);
if (p3)
+ {
_asn1_set_down (p3, p2);
+ p2 = NULL;
+ flag_t = 0;
+ }
else
{
if (p->right)
@@ -355,15 +359,19 @@ _asn1_delete_structure (list_type *e_list, asn1_node * structure, unsigned int f
}
}
else
- _asn1_set_right (p3, p2);
+ {
+ _asn1_set_right (p3,p2);
+ p2 = NULL;
+ flag_t = 0;
+ }
if (e_list)
_asn1_delete_node_from_list (e_list, p);
_asn1_remove_node (p, flags);
- p = NULL;
+ p = p2;
}
}
}
-
+if (flag_t)
*structure = NULL;
return ASN1_SUCCESS;
}
--
1.8.3.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openeuler-embedded/libtasn1.git
[email protected]:openeuler-embedded/libtasn1.git
openeuler-embedded
libtasn1
libtasn1
openEuler-embedded

搜索帮助