From 8af3a4cef86fca68a00124ca9d3b46eab297762f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Tue, 17 Dec 2024 20:43:40 +0100 Subject: [PATCH] lua: replace call to malloc by weechat_asprintf --- src/plugins/lua/weechat-lua.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/plugins/lua/weechat-lua.c b/src/plugins/lua/weechat-lua.c index c30454fcc..86504519a 100644 --- a/src/plugins/lua/weechat-lua.c +++ b/src/plugins/lua/weechat-lua.c @@ -190,7 +190,6 @@ weechat_lua_output_flush () { const char *ptr_command; char *temp_buffer, *command; - int length; if (!(*lua_buffer_output)[0]) return; @@ -219,12 +218,11 @@ weechat_lua_output_flush () } else { - length = 1 + strlen (temp_buffer) + 1; - command = malloc (length); - if (command) + if (weechat_asprintf (&command, + "%c%s", + temp_buffer[0], + temp_buffer) >= 0) { - snprintf (command, length, "%c%s", - temp_buffer[0], temp_buffer); weechat_command (lua_eval_buffer, (command[0]) ? command : " "); free (command);