Okay, so I'm newish to C, and I've been trying to learn by basically breaking stuff.
I'm developing on a Proxmark3 Easy, and I wanted to see if I could replace the Memory manager it uses. I got it all to compile, but I'm running into an issue with some of the new code and I have no clue how to try and fix it.
This is the repo in question: https://github.com/jlitewski/proxmark3/blob/nxtgen-palloc/armsrc/palloc.c
Attached is the local version of the code I'm working on.
So, the issue: Calling palloc_status() crashes the Proxmark3. It correctly displays the MEM_USABLE and free memory, and outputs that the heap isn't null. It goes into the count_blocks(pBlock* ptr) function, and prints that the heap and ptr are not null. As soon as ptr->next is called, it crashes.
What I gathered so far is there's possibly a problem with how the pointers are set up in palloc_init(). In the attached code, it gets to line 407 and it crashes there. I know the code on that line is weird, I've been throwing when I know at it to get it to work. All the structs are packed (since that was one of the issues I was having), and I'm on my wits end of trying to figure out why it's not working when ptr->next is invoked.