From 7318d393eafef5eaecffb74214767c0b15261b0b Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sat, 24 Jul 2021 11:31:07 -0400 Subject: [PATCH] libc: atoi() is supposed to return 0 if handed a NULL pointer Change-Id: I2d77532536ca83e5c9c2d7622a0e672082969f75 --- firmware/libc/atoi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/firmware/libc/atoi.c b/firmware/libc/atoi.c index 3393839b27..00617c3d13 100644 --- a/firmware/libc/atoi.c +++ b/firmware/libc/atoi.c @@ -26,7 +26,10 @@ int atoi (const char *str) { int value = 0; int sign = 1; - + + if (!str) + return 0; + while (isspace(*str)) { str++;