From 19a799656a93256fd107e2d3aa74c0dcee4f300c Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Wed, 7 Apr 2021 23:01:26 -0700 Subject: [PATCH] [kernel] Protect against null ctor This should never happen, but if there's a null in the ctors list, don't just blindly call it. --- src/kernel/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/kernel/main.cpp b/src/kernel/main.cpp index 4bfbfee..f578c01 100644 --- a/src/kernel/main.cpp +++ b/src/kernel/main.cpp @@ -78,7 +78,7 @@ run_constructors() void (**p)(void) = &__ctors; while (p < &__ctors_end) { void (*ctor)(void) = *p++; - ctor(); + if (ctor) ctor(); } } @@ -126,7 +126,6 @@ kernel_main(args::header *header) extern cpu_data g_bsp_cpu_data; extern uintptr_t idle_stack_end; - cpu_data *cpu = &g_bsp_cpu_data; kutil::memset(cpu, 0, sizeof(cpu_data));