diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-25 20:42:41 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-25 20:42:41 +0200 |
commit | 638d89cbc030f5d187bf29ff2f3c135b3f3bfeca (patch) | |
tree | d7de1ae88e2cd68560a19dae00856841629b77c7 | |
parent | k (diff) | |
download | 42-minishell-638d89cbc030f5d187bf29ff2f3c135b3f3bfeca.tar.gz 42-minishell-638d89cbc030f5d187bf29ff2f3c135b3f3bfeca.tar.bz2 42-minishell-638d89cbc030f5d187bf29ff2f3c135b3f3bfeca.tar.xz 42-minishell-638d89cbc030f5d187bf29ff2f3c135b3f3bfeca.tar.zst 42-minishell-638d89cbc030f5d187bf29ff2f3c135b3f3bfeca.zip |
Fixed segv on spaces only
-rw-r--r-- | src/ft_e_lcom.c | 3 | ||||
-rw-r--r-- | src/ft_m_loop.c | 1 | ||||
-rw-r--r-- | src/ft_s_lcom.c | 13 |
3 files changed, 10 insertions, 7 deletions
diff --git a/src/ft_e_lcom.c b/src/ft_e_lcom.c index 57998cb..3288112 100644 --- a/src/ft_e_lcom.c +++ b/src/ft_e_lcom.c @@ -39,8 +39,7 @@ void ptr = msh->curr; while (ptr != NULL) { - /* TODO: FIX THAT */ - if (ptr->com[0]) + if (ptr->com) { if ((bu_id = ft_get_builtin_id(ptr->com, msh)) < FT_BUILTINS_COUNT) { diff --git a/src/ft_m_loop.c b/src/ft_m_loop.c index 14f40a9..7f805a2 100644 --- a/src/ft_m_loop.c +++ b/src/ft_m_loop.c @@ -36,7 +36,6 @@ uint8_t ft_memdel((void*)&line); ft_e_lcom(msh); ft_lcom_clear(&msh->curr); - /* TODO: segv on spaces only "msh ~> " */ /* TODO: segv on ';' terminated lines "msh ~> echo qwe;" */ /* TODO: (null): Bad address on "msh ~> echo a > asd; cat < asd" but not on "msh ~> echo a > asd; cat asd" */ /* TODO: GNL 25 leak on "msh ~> exit" */ diff --git a/src/ft_s_lcom.c b/src/ft_s_lcom.c index 33ad5da..03b2f67 100644 --- a/src/ft_s_lcom.c +++ b/src/ft_s_lcom.c @@ -27,10 +27,15 @@ static int8_t uint64_t j; i = 0; - if (!((*lcom)->com = (char*)malloc((ft_strlen(words[0]) + 1) * - sizeof(char)))) - return (-1); - ft_strlcpy((*lcom)->com, words[0], ft_strlen(words[0]) + 1); + if (words[0]) + { + if (!((*lcom)->com = (char*)malloc((ft_strlen(words[0]) + 1) * + sizeof(char)))) + return (-1); + ft_strlcpy((*lcom)->com, words[0], ft_strlen(words[0]) + 1); + } + else + return (0); while(words[i]) { /* TODO: cut fd number "msh ~> echo a 2>file" */ |