Skip to content
Extraits de code Groupes Projets
Valider cd47cc5a rédigé par Etienne BRATEAU's avatar Etienne BRATEAU
Parcourir les fichiers

Fix wrong size of malloc in getword function

parent 753b1450
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -9,11 +9,9 @@ ...@@ -9,11 +9,9 @@
void getword(char *buf, char *wrd) void getword(char *buf, char *wrd)
{ {
char *str1; size_t len = strlen(buf);
char *str2; char *str1 = (char *) malloc(sizeof(char) * (len + 1));
char *str2 = (char *) malloc(sizeof(char) * (len + 1));
str1 = malloc(strlen(buf) + 1);
str2 = malloc(strlen(buf) + 1);
strcpy(str1, strltrim(strrtrim(strcpy(str2, buf)))); strcpy(str1, strltrim(strrtrim(strcpy(str2, buf))));
strcpy(buf, str1); strcpy(buf, str1);
free(str1); free(str1);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter