From 409a06982e2f98914433d2fb26a26af478eb756c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Thu, 25 Apr 2024 19:15:03 +0200 Subject: [PATCH] core: remove check of NULL pointers before calling string_dyn_free() (issue #865) --- src/core/core-eval.c | 3 +-- src/core/hook/hook-command.c | 3 +-- src/gui/gui-key.c | 6 ++---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/core/core-eval.c b/src/core/core-eval.c index 579ea816a..2317d4ba9 100644 --- a/src/core/core-eval.c +++ b/src/core/core-eval.c @@ -2787,8 +2787,7 @@ eval_expression (const char *expr, struct t_hashtable *pointers, /* set debug in options hashtable */ if (options && eval_context->debug_output) hashtable_set (options, "debug_output", *(eval_context->debug_output)); - if (eval_context->debug_output) - string_dyn_free (eval_context->debug_output, 1); + string_dyn_free (eval_context->debug_output, 1); return value; } diff --git a/src/core/hook/hook-command.c b/src/core/hook/hook-command.c index e6ac7781e..39963b16e 100644 --- a/src/core/hook/hook-command.c +++ b/src/core/hook/hook-command.c @@ -491,8 +491,7 @@ hook_command_format_args_description (const char *args_description) error: arraylist_free (args); - if (result) - string_dyn_free (result, 1); + string_dyn_free (result, 1); string_free_split (lines); return NULL; } diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c index a153ba99a..a38b6a522 100644 --- a/src/gui/gui-key.c +++ b/src/gui/gui-key.c @@ -819,10 +819,8 @@ gui_key_expand (const char *key, char **key_name, char **key_name_alias) return 1; error: - if (str_dyn_key) - string_dyn_free (str_dyn_key, 1); - if (str_dyn_key_alias) - string_dyn_free (str_dyn_key_alias, 1); + string_dyn_free (str_dyn_key, 1); + string_dyn_free (str_dyn_key_alias, 1); return 0; }