summaryrefslogtreecommitdiffstats
path: root/src/p_lblock_next.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/p_lblock_next.c')
-rw-r--r--src/p_lblock_next.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/p_lblock_next.c b/src/p_lblock_next.c
index 56a789d..8b22f7c 100644
--- a/src/p_lblock_next.c
+++ b/src/p_lblock_next.c
@@ -28,8 +28,8 @@
static char
*p_subst_this_var(char **p, int64_t i, char word[], t_msh *msh)
{
- char tmp[4096];
- char varval[4096];
+ char tmp[ARG_MAX];
+ char varval[ARG_MAX];
char *ptr;
size_t varlen;
@@ -42,7 +42,9 @@ static char
ft_strlcpy(tmp, ptr + i, varlen + 1 - i);
u_get_var_value(varval, tmp, 4096, msh);
ft_strlcpy(tmp, ptr + varlen, varlen);
- word = ft_nrealloc(word, i, i + ft_strlen(varval) + ft_strlen(tmp) + 1);
+ if ((word = ft_nrealloc(word, i, i + ft_strlen(varval) +
+ ft_strlen(tmp) + 1)) == NULL)
+ return (NULL);
ft_strlcpy(word + i, varval, ft_strlen(varval) + 1);
ft_strlcpy(word + (i + ft_strlen(varval)), tmp, ft_strlen(tmp) + 1);
*(p) = word + (i + ft_strlen(varval) - 1);
@@ -143,7 +145,7 @@ static char
j = 0;
while (words[i + j] != NULL)
j++;
- if (!(rewords = (char**)malloc((j + 1) * sizeof(char*))))
+ if ((rewords = (char**)malloc((j + 1) * sizeof(char*))) == NULL)
{
ft_delwords(words);
f_alloc_and_destroy_msh(msh);