Skip to content

Commit

Permalink
Fix NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
dmnks committed Nov 21, 2024
1 parent 93f2d30 commit d5de4c7
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions lib/rpmplugins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ struct rpmPlugins_s {

static rpmPlugin rpmpluginsGetPlugin(rpmPlugins plugins, const char *name)
{
if (!plugins)
return NULL;
for (auto & plugin : plugins->plugins) {
if (rstreq(plugin->name, name)) {
return plugin;
Expand Down Expand Up @@ -139,6 +141,8 @@ rpmRC rpmpluginsAdd(rpmPlugins plugins, const char *name, const char *path,
rpmRC rc;
rpmPlugin plugin = rpmPluginNew(name, path, opts);

if (plugins == NULL)
return RPMRC_OK;
if (plugin == NULL)
return RPMRC_FAIL;

Expand Down Expand Up @@ -235,6 +239,9 @@ rpmRC rpmpluginsCallTsmPre(rpmPlugins plugins, rpmts ts)
plugin_tsm_pre_func hookFunc;
rpmRC rc = RPMRC_OK;

if (!plugins)
return rc;

for (auto & plugin : plugins->plugins) {
RPMPLUGINS_SET_HOOK_FUNC(tsm_pre);
if (hookFunc && hookFunc(plugin, ts) == RPMRC_FAIL) {
Expand All @@ -251,6 +258,9 @@ rpmRC rpmpluginsCallTsmPost(rpmPlugins plugins, rpmts ts, int res)
plugin_tsm_post_func hookFunc;
rpmRC rc = RPMRC_OK;

if (!plugins)
return rc;

for (auto & plugin : plugins->plugins) {
RPMPLUGINS_SET_HOOK_FUNC(tsm_post);
if (hookFunc && hookFunc(plugin, ts, res) == RPMRC_FAIL) {
Expand All @@ -266,6 +276,9 @@ rpmRC rpmpluginsCallPsmPre(rpmPlugins plugins, rpmte te)
plugin_psm_pre_func hookFunc;
rpmRC rc = RPMRC_OK;

if (!plugins)
return rc;

for (auto & plugin : plugins->plugins) {
RPMPLUGINS_SET_HOOK_FUNC(psm_pre);
if (hookFunc && hookFunc(plugin, te) == RPMRC_FAIL) {
Expand All @@ -282,6 +295,9 @@ rpmRC rpmpluginsCallPsmPost(rpmPlugins plugins, rpmte te, int res)
plugin_psm_post_func hookFunc;
rpmRC rc = RPMRC_OK;

if (!plugins)
return rc;

for (auto & plugin : plugins->plugins) {
RPMPLUGINS_SET_HOOK_FUNC(psm_post);
if (hookFunc && hookFunc(plugin, te, res) == RPMRC_FAIL) {
Expand All @@ -297,6 +313,9 @@ rpmRC rpmpluginsCallScriptletPre(rpmPlugins plugins, const char *s_name, int typ
plugin_scriptlet_pre_func hookFunc;
rpmRC rc = RPMRC_OK;

if (!plugins)
return rc;

for (auto & plugin : plugins->plugins) {
RPMPLUGINS_SET_HOOK_FUNC(scriptlet_pre);
if (hookFunc && hookFunc(plugin, s_name, type) == RPMRC_FAIL) {
Expand All @@ -313,6 +332,9 @@ rpmRC rpmpluginsCallScriptletForkPost(rpmPlugins plugins, const char *path, int
plugin_scriptlet_fork_post_func hookFunc;
rpmRC rc = RPMRC_OK;

if (!plugins)
return rc;

for (auto & plugin : plugins->plugins) {
RPMPLUGINS_SET_HOOK_FUNC(scriptlet_fork_post);
if (hookFunc && hookFunc(plugin, path, type) == RPMRC_FAIL) {
Expand All @@ -329,6 +351,9 @@ rpmRC rpmpluginsCallScriptletPost(rpmPlugins plugins, const char *s_name, int ty
plugin_scriptlet_post_func hookFunc;
rpmRC rc = RPMRC_OK;

if (!plugins)
return rc;

for (auto & plugin : plugins->plugins) {
RPMPLUGINS_SET_HOOK_FUNC(scriptlet_post);
if (hookFunc && hookFunc(plugin, s_name, type, res) == RPMRC_FAIL) {
Expand All @@ -352,8 +377,11 @@ rpmRC rpmpluginsCallFsmFilePre(rpmPlugins plugins, rpmfi fi, const char *path,
{
plugin_fsm_file_pre_func hookFunc;
rpmRC rc = RPMRC_OK;
char *apath = abspath(fi, path);

if (!plugins)
return rc;

char *apath = abspath(fi, path);
for (auto & plugin : plugins->plugins) {
RPMPLUGINS_SET_HOOK_FUNC(fsm_file_pre);
if (hookFunc && hookFunc(plugin, fi, apath, file_mode, op) == RPMRC_FAIL) {
Expand All @@ -371,8 +399,11 @@ rpmRC rpmpluginsCallFsmFilePost(rpmPlugins plugins, rpmfi fi, const char *path,
{
plugin_fsm_file_post_func hookFunc;
rpmRC rc = RPMRC_OK;
char *apath = abspath(fi, path);

if (!plugins)
return rc;

char *apath = abspath(fi, path);
for (auto & plugin : plugins->plugins) {
RPMPLUGINS_SET_HOOK_FUNC(fsm_file_post);
if (hookFunc && hookFunc(plugin, fi, apath, file_mode, op, res) == RPMRC_FAIL) {
Expand All @@ -390,8 +421,11 @@ rpmRC rpmpluginsCallFsmFilePrepare(rpmPlugins plugins, rpmfi fi,
{
plugin_fsm_file_prepare_func hookFunc;
rpmRC rc = RPMRC_OK;
char *apath = abspath(fi, path);

if (!plugins)
return rc;

char *apath = abspath(fi, path);
for (auto & plugin : plugins->plugins) {
RPMPLUGINS_SET_HOOK_FUNC(fsm_file_prepare);
if (hookFunc && hookFunc(plugin, fi, fd, apath, dest, file_mode, op) == RPMRC_FAIL) {
Expand Down

0 comments on commit d5de4c7

Please sign in to comment.