From 269b8fc66e45edb02a58bbee5d4c510873e53951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 29 Jan 2023 21:20:18 +0100 Subject: core: properly skip command char when it is a wide char in exec of hook_command_run --- src/core/hook/wee-hook-command-run.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/hook/wee-hook-command-run.c b/src/core/hook/wee-hook-command-run.c index 9eb3b183e..7d95d8042 100644 --- a/src/core/hook/wee-hook-command-run.c +++ b/src/core/hook/wee-hook-command-run.c @@ -103,7 +103,7 @@ hook_command_run_exec (struct t_gui_buffer *buffer, const char *command) struct t_hook *ptr_hook, *next_hook; int rc, hook_matching, length; char *command2; - const char *ptr_command; + const char *ptr_string, *ptr_command; if (!weechat_hooks[HOOK_TYPE_COMMAND_RUN]) return WEECHAT_RC_OK; @@ -113,11 +113,12 @@ hook_command_run_exec (struct t_gui_buffer *buffer, const char *command) if (command[0] != '/') { - length = strlen (command) + 1; + ptr_string = utf8_next_char (command); + length = 1 + strlen (ptr_string) + 1; command2 = malloc (length); if (command2) { - snprintf (command2, length, "/%s", command + 1); + snprintf (command2, length, "/%s", ptr_string); ptr_command = command2; } } -- cgit v1.2.3