summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/main.c2
-rw-r--r--src/kernel/settings.c8
-rw-r--r--src/kernel/settings.h1
-rw-r--r--src/kernel/window.c8
4 files changed, 18 insertions, 1 deletions
diff --git a/src/kernel/main.c b/src/kernel/main.c
index 9699029..951e37f 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -47,6 +47,8 @@ void main() {
init_idt();
init_win();
+ close_settings();
+
logf(LOG_INFO, "Kernel initialization done.");
logf(LOG_INFO, "Available kernel memory: %dk", kernel_pages_left * 4);
logf(LOG_INFO, "Available user memory: %dk", user_pages_left * 4);
diff --git a/src/kernel/settings.c b/src/kernel/settings.c
index 699196b..419341a 100644
--- a/src/kernel/settings.c
+++ b/src/kernel/settings.c
@@ -36,6 +36,11 @@ struct main_entry {
static file_id_t fid;
static uint32_t main_end;
+void close_settings() {
+ drives->free_file(drives, fid);
+ fid = 0;
+}
+
void init_settings() {
fid = drives->get_file(drives, SETTINGS_FILE);
if (!fid)
@@ -47,6 +52,9 @@ void init_settings() {
}
bool try_find_setting(const char *name, struct main_entry *entry_out) {
+ if (!fid)
+ PANIC("setting requested after settings file closed");
+
uint16_t name_len = 0;
while (name[name_len])
if (++name_len == 256)
diff --git a/src/kernel/settings.h b/src/kernel/settings.h
index f25d4df..ec5e9f5 100644
--- a/src/kernel/settings.h
+++ b/src/kernel/settings.h
@@ -7,6 +7,7 @@
#include <stdint.h>
void init_settings();
+void close_settings();
//lengths do not include null terminator. if setting value is too long, it is cropped.
bool try_get_sz_setting(const char *name, char *out, uint32_t max_len, uint32_t *len_out);
diff --git a/src/kernel/window.c b/src/kernel/window.c
index 4b01bc4..69babe4 100644
--- a/src/kernel/window.c
+++ b/src/kernel/window.c
@@ -330,9 +330,15 @@ got_window:
}
static void del_no_paint(struct window *w) {
+ if ((w < windows) || (w >= windows + MAX_WINDOWS) || (((void *)w - (void *)windows) % sizeof(struct window))) {
+ logf(LOG_WARN, "Refusing to delete bad window pointer 0x%h", w);
+ return;
+ }
+
if (w == top_window) {
top_window = w->below;
- send_action(top_window, (struct window_action){.action_type = FOCUS_ENTER});
+ if (top_window)
+ send_action(top_window, (struct window_action){.action_type = FOCUS_ENTER});
}
if (w == bottom_window)
bottom_window = w->above;