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++) {