Just return 0 when passing NULL string to atoi

This commit is contained in:
Enrico Fraccaroli
2019-05-10 12:00:03 +02:00
parent 07bd4d7901
commit dbeed54f2b
+3 -2
View File
@@ -9,7 +9,6 @@
#include "keyboard.h"
#include "unistd.h"
#include "debug.h"
#include "assert.h"
void putchar(int character)
{
@@ -74,7 +73,9 @@ char *gets(char *str)
int atoi(const char *str)
{
assert(str && "Received NULL string.");
// Check the input string.
if (str == NULL)
return 0;
// Initialize sign.
int sign = (str[0] == '-') ? -1 : +1;
// Initialize the result.