From: Federico klez Culloca Date: Sun, 14 Jun 2026 11:16:26 +0000 (+0200) Subject: oops, that's not how you copy strings... X-Git-Url: https://git.klezlab.it/?a=commitdiff_plain;ds=inline;p=klez%2Fparrotsay-lite.git oops, that's not how you copy strings... --- diff --git a/parrotsay.c b/parrotsay.c index 9f9c528..c6c939e 100644 --- a/parrotsay.c +++ b/parrotsay.c @@ -69,7 +69,7 @@ void read_from_args(char** message_rows, int argc, char** argv) { for (int i = 1; i < argc; i++) { size_t message_rows_length = strlen(*message_rows) + strlen(*(argv+i)) - + (i == 1 ? 0 : 1); + + (i == 1 ? 1 : 2); // must include \0 and space char* tmp = realloc(*message_rows, message_rows_length); if (tmp == NULL) { fprintf(stderr, "Error: %s", strerror(errno)); @@ -77,9 +77,9 @@ void read_from_args(char** message_rows, int argc, char** argv) { } *message_rows = tmp; if (i != 1) { - strlcat(*message_rows, " ", message_rows_length + 1); + strlcat(*message_rows, " ", message_rows_length); } - strlcat(*message_rows, *(argv + i), message_rows_length + 1); + strlcat(*message_rows, *(argv + i), message_rows_length); } }