strcmp protection
This commit is contained in:
parent
81fa664170
commit
034c988135
2 changed files with 4 additions and 2 deletions
|
|
@ -27,8 +27,8 @@ char **ft_sstradd(char **sstr, char *new)
|
|||
return (NULL);
|
||||
if (sstr)
|
||||
ft_memcpy(newlist, sstr, sizeof(char*) * size);
|
||||
newlist[size++] = ft_strdup(new);
|
||||
newlist[size] = NULL;
|
||||
newlist[size] = ft_strdup(new);
|
||||
newlist[size + 1] = NULL;
|
||||
free(sstr);
|
||||
return (newlist);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ int ft_strcmp(const char *s1, const char *s2)
|
|||
int i;
|
||||
|
||||
i = 0;
|
||||
if (!s1 || !s2)
|
||||
return (1);
|
||||
while (*(s1 + i) && *(s1 + i) == *(s2 + i))
|
||||
i++;
|
||||
return (*((unsigned char*)s1 + i) - *((unsigned char*)s2 + i));
|
||||
|
|
|
|||
Loading…
Reference in a new issue