From: chaoskagami Date: Fri, 2 Sep 2016 06:59:11 +0000 (-0400) Subject: Ugh X-Git-Tag: v0.3.0~21 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=77e349a0fe8528ad0db9970aba2c10727ffbf99e;p=corbenik%2Fcorbenik.git Ugh --- diff --git a/source/firm/version.c b/source/firm/version.c index a24d5a8..9db7067 100644 --- a/source/firm/version.c +++ b/source/firm/version.c @@ -7,7 +7,9 @@ get_firm_info(firm_h *firm) struct firm_signature *signature = (struct firm_signature*)malloc(sizeof(struct firm_signature)); - signature->type = type_native; + signature->type = type_native; + signature->k9l = 0; + signature->console = console_o3ds; // Test: Is section #4 a stub // True: If true, must be NFIRM. diff --git a/source/std/allocator.c b/source/std/allocator.c index 1b61df7..e0c4eec 100644 --- a/source/std/allocator.c +++ b/source/std/allocator.c @@ -31,6 +31,9 @@ typedef struct free_block { const char* info; #endif struct free_block* next; + + uint32_t canary; + uint32_t pad[3]; // Otherwise, not a 16-multiple } free_block; static free_block free_block_list_head = { @@ -39,7 +42,9 @@ static free_block free_block_list_head = { #ifdef MALLOC_DEBUG NULL, #endif - 0 + 0, + 0, + {0} }; static const size_t align_to = 64; @@ -81,6 +86,7 @@ void* malloc(size_t size) { block = (free_block*)sbrk(bsize); block->size = bsize; block->real_size = size; + block->canary = 0x1337d00d; // Arbitrary. No special meaning. #ifdef MALLOC_DEBUG block->info = info; @@ -111,6 +117,10 @@ void free(void* ptr) { free_block* block = (free_block*)(((char*)ptr) - sizeof(free_block )); #ifdef MALLOC_DEBUG + if (block->canary != 0x1337d00d) { + abort("%s: Attempt free non-pointer.\n", info); + } + ++free_count; if (allocated_memory < block->size) { fprintf(stderr, "%s: Invalid free detected.\n"