From 740fcb11c29872cc22048a90d64e45e97c78d2c0 Mon Sep 17 00:00:00 2001 From: 0xf8 <0xf8.dev@proton.me> Date: Sat, 25 Feb 2023 12:46:53 -0500 Subject: [PATCH] Allow any variable-sized message Signed-off-by: 0xf8 <0xf8.dev@proton.me> --- rbtext.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rbtext.c b/rbtext.c index ec32c3b..09b019a 100644 --- a/rbtext.c +++ b/rbtext.c @@ -59,7 +59,12 @@ int main(int argc, char **argv) { return 1; } - char *text = (char *)malloc(1024 + 1); + uint reqSize = 0; + for (int i = 1; i < argc; i++) { + reqSize += strlen(argv[i]); + } + + char *text = (char *)malloc(reqSize + argc); // Adds all the arguments together with spaces seperating them for (int i = 1, j = 0; i < argc; i++) {