From 45bfdffcb2e00fda595b3f9318469f6b0d29cbe4 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 18 May 2021 22:06:59 +0200 Subject: Fixed issues with intel emulation --- libs/libc/alloc.c | 10 +++++----- libs/libc/print.c | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'libs') diff --git a/libs/libc/alloc.c b/libs/libc/alloc.c index bc48502..ea01a38 100644 --- a/libs/libc/alloc.c +++ b/libs/libc/alloc.c @@ -125,7 +125,7 @@ void *_malloc(u32 req_size) if (size == 0) { liballoc_unlock(); - return malloc(1); + return _malloc(1); } if (l_mem_root == NULL) { @@ -338,12 +338,12 @@ void *_realloc(void *ptr, u32 size) size = ALIGN_UP(size, 16); if (size == 0) { - free(ptr); + _free(ptr); return NULL; } if (ptr == NULL) - return malloc(size); + return _malloc(size); liballoc_lock(); struct liballoc_minor *min = (struct liballoc_minor *)((u32)ptr - MINOR_SIZE); @@ -361,9 +361,9 @@ void *_realloc(void *ptr, u32 size) liballoc_unlock(); - void *new_ptr = malloc(size); + void *new_ptr = _malloc(size); memcpy(new_ptr, ptr, min->req_size); - free(ptr); + _free(ptr); return new_ptr; } diff --git a/libs/libc/print.c b/libs/libc/print.c index c4455eb..463fef6 100644 --- a/libs/libc/print.c +++ b/libs/libc/print.c @@ -241,6 +241,8 @@ void print_trace(u32 count) __asm__ volatile("movl %%ebp, %0;" : "=r"(stk)); print("EBP\tEIP\n"); for (u32 i = 0; stk && memory_readable(stk) && i < count; i++) { + if (!stk->ebp || !stk->eip) + break; printf("0x%x\t0x%x\n", stk->ebp, stk->eip); stk = stk->ebp; } -- cgit v1.2.3