summaryrefslogtreecommitdiff
path: root/src/plugins/python
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-04-24 23:41:01 +0200
committerSébastien Helleu <flashcode@flashtux.org>2024-04-25 20:59:24 +0200
commitb138510cff23b9d12e78af8872eecaa62f22f3f8 (patch)
tree601b132f73ca8c96aff8086dd8ca75f95e9f33a5 /src/plugins/python
parentc472b9a733e06f044a6bc7a502a9604c333b6fc7 (diff)
downloadweechat-b138510cff23b9d12e78af8872eecaa62f22f3f8.zip
python: remove check of NULL pointers before calling free() (issue #865)
Diffstat (limited to 'src/plugins/python')
-rw-r--r--src/plugins/python/weechat-python-api.c11
-rw-r--r--src/plugins/python/weechat-python.c18
2 files changed, 9 insertions, 20 deletions
diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c
index 654b33cec..ca9757234 100644
--- a/src/plugins/python/weechat-python-api.c
+++ b/src/plugins/python/weechat-python-api.c
@@ -1273,9 +1273,7 @@ weechat_python_api_config_option_change_cb (const void *pointer, void *data,
WEECHAT_SCRIPT_EXEC_IGNORE,
ptr_function,
"ss", func_argv);
-
- if (rc)
- free (rc);
+ free (rc);
}
}
@@ -1300,9 +1298,7 @@ weechat_python_api_config_option_delete_cb (const void *pointer, void *data,
WEECHAT_SCRIPT_EXEC_IGNORE,
ptr_function,
"ss", func_argv);
-
- if (rc)
- free (rc);
+ free (rc);
}
}
@@ -3010,8 +3006,7 @@ weechat_python_api_hook_print_cb (const void *pointer, void *data,
ret = *rc;
free (rc);
}
- if (func_argv[3])
- free (func_argv[3]);
+ free (func_argv[3]);
return ret;
}
diff --git a/src/plugins/python/weechat-python.c b/src/plugins/python/weechat-python.c
index cb9d5c6a9..7bc3e9247 100644
--- a/src/plugins/python/weechat-python.c
+++ b/src/plugins/python/weechat-python.c
@@ -274,10 +274,8 @@ weechat_python_dict_to_hashtable (PyObject *dict, int size,
}
}
- if (str_key)
- free (str_key);
- if (str_value)
- free (str_value);
+ free (str_key);
+ free (str_value);
}
return hashtable;
@@ -925,8 +923,7 @@ weechat_python_unload (struct t_plugin_script *script)
{
rc = (int *) weechat_python_exec (script, WEECHAT_SCRIPT_EXEC_INT,
script->shutdown_func, NULL, NULL);
- if (rc)
- free (rc);
+ free (rc);
}
filename = strdup (script->filename);
@@ -952,8 +949,7 @@ weechat_python_unload (struct t_plugin_script *script)
(void) weechat_hook_signal_send ("python_script_unloaded",
WEECHAT_HOOK_SIGNAL_STRING, filename);
- if (filename)
- free (filename);
+ free (filename);
}
/*
@@ -1069,8 +1065,7 @@ weechat_python_eval (struct t_gui_buffer *buffer, int send_to_buffer_as_input,
"script_python_eval",
"s", func_argv);
/* result is ignored */
- if (result)
- free (result);
+ free (result);
weechat_python_output_flush ();
@@ -1176,8 +1171,7 @@ weechat_python_command_cb (const void *pointer, void *data,
ptr_name, 1);
weechat_python_load ((path_script) ? path_script : ptr_name,
NULL);
- if (path_script)
- free (path_script);
+ free (path_script);
}
else if (weechat_strcmp (argv[1], "reload") == 0)
{