]> Chaos Git - corbenik/corbenik.git/commitdiff
Ugh
authorchaoskagami <chaos.kagami@gmail.com>
Fri, 2 Sep 2016 06:59:11 +0000 (02:59 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Fri, 2 Sep 2016 07:05:11 +0000 (03:05 -0400)
source/firm/version.c
source/std/allocator.c

index a24d5a8502c5f9143bcffd19f16ef47a26887f97..9db7067b9f62c40a9345d81ca351cf83ed5bdaf4 100644 (file)
@@ -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.
index 1b61df7a337886867ce4bdb98668b75f089b31d4..e0c4eecfdeb2f29d73357fe1954d85fcd9a4fd13 100644 (file)
@@ -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"