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
Branches
Étiquettes
Aucune requête de fusion associée trouvée
......@@ -9,11 +9,9 @@
void getword(char *buf, char *wrd)
{
char *str1;
char *str2;
str1 = malloc(strlen(buf) + 1);
str2 = malloc(strlen(buf) + 1);
size_t len = strlen(buf);
char *str1 = (char *) malloc(sizeof(char) * (len + 1));
char *str2 = (char *) malloc(sizeof(char) * (len + 1));
strcpy(str1, strltrim(strrtrim(strcpy(str2, buf))));
strcpy(buf, str1);
free(str1);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter