summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-07-30 19:19:38 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-07-30 19:19:38 +0200
commite18c67950ddd57b65933cb46cbd7d77e74f00faa (patch)
tree14cb0be6d6bc34d7248825d3871e3d90a56986ff
parentI'm retarded (diff)
download42-minishell-e18c67950ddd57b65933cb46cbd7d77e74f00faa.tar.gz
42-minishell-e18c67950ddd57b65933cb46cbd7d77e74f00faa.tar.bz2
42-minishell-e18c67950ddd57b65933cb46cbd7d77e74f00faa.tar.xz
42-minishell-e18c67950ddd57b65933cb46cbd7d77e74f00faa.tar.zst
42-minishell-e18c67950ddd57b65933cb46cbd7d77e74f00faa.zip
Secured strdup
-rw-r--r--src/u_vars.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/u_vars.c b/src/u_vars.c
index 9978df5..377da77 100644
--- a/src/u_vars.c
+++ b/src/u_vars.c
@@ -127,7 +127,12 @@ static char
}
if (ptr != NULL)
{
- varval = ft_strdup(ptr->val);
+ if (!(varval = ft_strdup(ptr->val)))
+ {
+ lcom_clear(&msh->curr);
+ s_destroy(msh);
+ fail_alloc(msh);
+ }
return (varval);
}
else