Merge pull request #807 from BillKek/master

fix: assertion failed on negative numbers in `conversions/c_atoi_str_to_integer.c`
This commit is contained in:
Ayaan Khan 2021-02-28 23:04:02 +05:30 committed by GitHub
commit 121c7132a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -30,9 +30,15 @@ int c_atoi(const char *str)
/* store the sign if it is negative sign */
if (str[i] == '-')
{
sign = -1;
i++;
}
else if (str[i] == '+')
{
sign = 1;
i++;
}
/* converting char by char to a numeric value */
while (str[i] >= 48 && str[i] <= 57 && str[i] != '\0')