Browse Source

[enh] strjoinf: free two strings at char insertion.

Moul 3 years ago
parent
commit
636a7d6c81
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/ft_strjoinf.c

+ 3 - 1
src/ft_strjoinf.c

@@ -21,6 +21,8 @@ char	*ft_strjoinf(char const *s1, char const *s2, int p)
 	str = ft_strnew(ft_strlen(s1) + ft_strlen(s2));
 	ft_strcpy(str, s1);
 	str = ft_strcat(str, s2);
-	(p == 1) ? ft_strdel((char **)&s1) : ft_strdel((char **)&s2);
+	(p == 1 && p == 3) ? ft_strdel((char **)&s1) : ft_strdel((char **)&s2);
+	if (p == 3)
+		ft_strdel((char**)&s2);
 	return (str);
 }