fix: strcmp protection with NULL args

This commit is contained in:
2024-09-27 12:03:52 +02:00
parent 0bcc99997a
commit f65d5ce418
2 changed files with 6 additions and 7 deletions

View File

@ -4,6 +4,8 @@ int strcmp(const char *s1, const char *s2)
{
size_t i = 0;
if (!s1 || !s2)
return -1;
while (s1[i] == s2[i] && s1[i] != '\0')
i++;
return s1[i] - s2[i];