!48 add check after malloc allocation

From: @anonymous_z 
Reviewed-by: @t_feng 
Signed-off-by: @t_feng
This commit is contained in:
openeuler-ci-bot 2023-04-21 09:40:28 +00:00 committed by Gitee
commit 9f8abdef56
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 36 additions and 1 deletions

View File

@ -0,0 +1,31 @@
From 466bd9dd8b8836af34f29976a5b0b83950bbe8ed Mon Sep 17 00:00:00 2001
From: Li kunyu <kunyu@nfschina.com>
Date: Mon, 19 Dec 2022 15:20:42 +0800
Subject: [PATCH] example_plugin: Add check after malloc allocation
Reference:https://github.com/rpm-software-management/libdnf/commit/466bd9dd8b8836af34f29976a5b0b83950bbe8ed
Conflict:NA
---
plugins/example_plugin.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/plugins/example_plugin.c b/plugins/example_plugin.c
index 3f1b119f31..a12439bffd 100644
--- a/plugins/example_plugin.c
+++ b/plugins/example_plugin.c
@@ -78,9 +78,11 @@ PluginHandle * pluginInitHandle(int version, PluginMode mode, DnfPluginInitData
break;
}
handle = malloc(sizeof(*handle));
- handle->mode = mode;
- handle->context = pluginGetContext(initData);
- handle->outStream = outStream;
+ if (handle) {
+ handle->mode = mode;
+ handle->context = pluginGetContext(initData);
+ handle->outStream = outStream;
+ }
} while (0);
fprintf(outStream, "%s: %s: exit =========================\n", info.name, __func__);

View File

@ -18,7 +18,7 @@
Name: libdnf
Version: 0.69.0
Release: 3
Release: 4
Summary: Library providing simplified C and Python API to libsolv
License: LGPLv2+
URL: https://github.com/rpm-software-management/libdnf
@ -44,6 +44,7 @@ Patch6000: backport-query-py-ensure-reldep-is-from-the-same-sack
%ifarch loongarch64
Patch6001: 0001-libdnf-0.65.0-add-loongarch-support.patch
%endif
Patch6002: backport-Add-check-after-malloc-allocation.patch
%description
A Library providing simplified C and Python API to libsolv.
@ -123,6 +124,9 @@ popd
%{python3_sitearch}/hawkey/
%changelog
* Fri Apr 21 2023 zhangrui <zhangrui182@huawei.com> - 0.69.0-4
- DESC:add check after malloc allocation
* Thu Jan 5 2023 zhangrui <zhangrui182@huawei.com> - 0.69.0-3
- DESC:add loongarch