소스 검색

Amélioration gestion memoire string nom fichier redir

Loquicom 6 년 전
부모
커밋
1ff4e023df
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      parser.c

+ 2 - 2
parser.c

@@ -386,8 +386,8 @@ int set_redirection(Command* c){
             buffer++;
         }
         //Allocation file et copie nom fichier
-        file = malloc(sizeof(char) * compteur);
-        memset(file, 0, compteur);
+        file = malloc(sizeof(char) * (compteur + 1));
+        memset(file, 0, compteur + 1);
         strncpy(file, deb, compteur);
         //Redirection
         if(set_io(c, file, redir) == SHELL_ERR){