32 lines
1.1 KiB
Diff
32 lines
1.1 KiB
Diff
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__);
|