: nply/fiche2

commit caa6f5ed6a35512f820d46026036fa80734be6b3
parent 1bc2132e1d13cebf8b2dba84fcfebd34c0da94cf
Author: Renaud Allard <renaud@allard.it>
Date: Thu, 27 Aug 2015 14:59:08 +0200

Former patch had a small bug, this has been corrected
1 file changed, 2 insertions(+), 2 deletions(-)
M
fiche.c
|
4
++--
diff --git a/fiche.c b/fiche.c
@@ -286,7 +286,7 @@ void generate_url(char *buffer, char *slug, size_t slug_length, struct client_da
 
 int create_directory(char *slug)
 {
-    char *directory = malloc(strlen(BASEDIR) + strlen(slug) + 2);
+    char *directory = malloc(strlen(BASEDIR) + strlen(slug) + sizeof(char) + 1);
 
     strcpy(directory, BASEDIR);
     strcat(directory, "/");

@@ -304,7 +304,7 @@ int create_directory(char *slug)
 
 void save_to_file(char *slug, char *buffer, struct client_data data)
 {
-    char *directory = malloc(strlen(BASEDIR) + strlen(slug) + strlen("/index.txt") + 2);
+    char *directory = malloc(strlen(BASEDIR) + strlen(slug) + strlen("/index.txt") + sizeof(char) + 1 );
     strcpy(directory, BASEDIR);
     strcat(directory, "/");
     strcat(directory, slug);