From fbf1e1584ea953c54893f189a5e5c8495fe319a7 Mon Sep 17 00:00:00 2001 From: mintsuki Date: Sun, 17 Apr 2022 07:51:28 +0200 Subject: [PATCH] term/protos: Do not call callback if NULL --- common/protos/limine.c | 10 ++++++---- common/protos/stivale2.c | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/common/protos/limine.c b/common/protos/limine.c index 37c3a267..6401e2f8 100644 --- a/common/protos/limine.c +++ b/common/protos/limine.c @@ -494,12 +494,14 @@ FEAT_START fb = fbinfo; + if (terminal_request->callback != 0) { #if defined (__i386__) - term_callback = stivale2_term_callback; - stivale2_term_callback_ptr = terminal_request->callback; + term_callback = stivale2_term_callback; + stivale2_term_callback_ptr = terminal_request->callback; #elif defined (__x86_64__) - term_callback = (void *)terminal_request->callback; + term_callback = (void *)terminal_request->callback; #endif + } term_arg = reported_addr(terminal); @@ -731,7 +733,7 @@ FEAT_START memmap_request->response = reported_addr(memmap_response); FEAT_END - // Clear terminal for kernels that will use the stivale2 terminal + // Clear terminal for kernels that will use the Limine terminal term_write((uint64_t)(uintptr_t)("\e[2J\e[H"), 7); term_runtime = true; diff --git a/common/protos/stivale2.c b/common/protos/stivale2.c index 26161e22..8080ebf3 100644 --- a/common/protos/stivale2.c +++ b/common/protos/stivale2.c @@ -555,12 +555,14 @@ failed_to_load_header_section: if (terminal_hdr_tag->flags & (1 << 0)) { // We provide callback tag->flags |= (1 << 2); + if (terminal_hdr_tag->callback != 0) { #if defined (__i386__) - term_callback = stivale2_term_callback; - stivale2_term_callback_ptr = terminal_hdr_tag->callback; + term_callback = stivale2_term_callback; + stivale2_term_callback_ptr = terminal_hdr_tag->callback; #elif defined (__x86_64__) - term_callback = (void *)terminal_hdr_tag->callback; + term_callback = (void *)terminal_hdr_tag->callback; #endif + } } // We provide max allowed string length