summaryrefslogtreecommitdiff
path: root/src/init
diff options
context:
space:
mode:
authordzwdz2021-10-10 15:36:53 +0000
committerdzwdz2021-10-10 15:36:53 +0000
commitac2252793a6e2a380bd215f62291ca2fe4f973b2 (patch)
tree9708f1e2ad3961f360cf509ee437d258134e16c2 /src/init
parentba69471edd732efa8a9b435299b82bfc482e0756 (diff)
init/printf: allow passing a nullptr to %s
Diffstat (limited to 'src/init')
-rw-r--r--src/init/stdlib.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/init/stdlib.c b/src/init/stdlib.c
index a60854b..4bc90d2 100644
--- a/src/init/stdlib.c
+++ b/src/init/stdlib.c
@@ -39,8 +39,10 @@ int printf(const char *fmt, ...) {
switch (c) {
case 's':
const char *s = va_arg(argp, char*);
- _syscall_write(0, s, strlen(s), 0);
- total += strlen(s);
+ if (s) {
+ _syscall_write(0, s, strlen(s), 0);
+ total += strlen(s);
+ }
break;
case 'x':