From 6eaf0de2eee17d85f38d6f71968aa078011e1bb1 Mon Sep 17 00:00:00 2001 From: Alessandro Ferro Date: Sat, 29 Apr 2023 15:26:03 +0200 Subject: [PATCH] String length error --- dircomp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dircomp.c b/dircomp.c index b7bedb7..3de0f51 100644 --- a/dircomp.c +++ b/dircomp.c @@ -19,8 +19,8 @@ int main(int argc, char *argv[]) return 0; } - char* directory_to_analyze1 = malloc(strlen(arguments.directory1) * sizeof(char)); - char* directory_to_analyze2 = malloc(strlen(arguments.directory2) * sizeof(char)); + char* directory_to_analyze1 = malloc(strlen(arguments.directory1) * sizeof(char) + 1); + char* directory_to_analyze2 = malloc(strlen(arguments.directory2) * sizeof(char) + 1); strcpy(directory_to_analyze1, arguments.directory1); strcpy(directory_to_analyze2, arguments.directory2); free(arguments.directory1);