From b80e3ff7928df5ba52ba1f40d52c7964286c41ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Fri, 29 Dec 2017 09:25:56 +0100 Subject: [PATCH] perl: do not update message argument in function weechat_perl_output (issue #128) --- src/plugins/perl/weechat-perl.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/perl/weechat-perl.c b/src/plugins/perl/weechat-perl.c index 31671d8ab..9ad5e0a16 100644 --- a/src/plugins/perl/weechat-perl.c +++ b/src/plugins/perl/weechat-perl.c @@ -278,7 +278,7 @@ weechat_perl_output_flush () XS (weechat_perl_output) { - char *msg, *ptr_msg, *ptr_newline; + char *msg, *ptr_msg, *ptr_newline, *message; dXSARGS; if (items < 1) @@ -288,10 +288,11 @@ XS (weechat_perl_output) ptr_msg = msg; while ((ptr_newline = strchr (ptr_msg, '\n')) != NULL) { - ptr_newline[0] = '\0'; - weechat_string_dyn_concat (perl_buffer_output, ptr_msg); + message = weechat_strndup (ptr_msg, ptr_newline - ptr_msg); + weechat_string_dyn_concat (perl_buffer_output, message); + if (message) + free (message); weechat_perl_output_flush (); - ptr_newline[0] = '\n'; ptr_msg = ++ptr_newline; } weechat_string_dyn_concat (perl_buffer_output, ptr_msg);