From 422a2c28cc213983a0acd4e3fbf0a14f2db48789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20=C5=A0vagelj?= Date: Thu, 30 May 2024 19:45:34 +0200 Subject: [PATCH 1/2] Replace strncat with strcat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pwithcolors is allocated based on computed length so strncat produces a warning. Signed-off-by: Tin Švagelj --- src/scroll.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scroll.cc b/src/scroll.cc index f7b5c23ce..67206cda7 100644 --- a/src/scroll.cc +++ b/src/scroll.cc @@ -271,11 +271,11 @@ void print_scroll(struct text_object *obj, char *p, unsigned int p_max_size) { } int pwithcolors_len = strlen(p) + 4 + colorchanges - visibcolorchanges; - char *pwithcolors = static_cast(malloc(pwithcolors_len)); + char *pwithcolors = new char[pwithcolors_len]; for (j = 0; j < frontcolorchanges; j++) { pwithcolors[j] = SPECIAL_CHAR; } pwithcolors[j] = 0; - strncat(pwithcolors, p, pwithcolors_len); + strcat(pwithcolors, p); unsigned int strend = strlen(pwithcolors); // and place the colorchanges not in front or in the visible part behind the // visible part From afccc20fac53f3943963f50b8914d7c694b4a0ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20=C5=A0vagelj?= Date: Sat, 1 Jun 2024 16:17:08 +0200 Subject: [PATCH 2/2] Replace free with delete MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tin Švagelj --- src/scroll.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scroll.cc b/src/scroll.cc index 67206cda7..0d4065e57 100644 --- a/src/scroll.cc +++ b/src/scroll.cc @@ -284,7 +284,7 @@ void print_scroll(struct text_object *obj, char *p, unsigned int p_max_size) { } pwithcolors[strend + j] = 0; strncpy(p, pwithcolors, p_max_size); - free(pwithcolors); + delete[] pwithcolors; // scroll if (sd->direction == SCROLL_LEFT) {