Skip to content

AllocationHeader is not copied from stack to the memory position #8

@talhasaruhan

Description

@talhasaruhan

In StackAllocator you're doing this:

AllocationHeader allocationHeader{padding}; AllocationHeader * headerPtr = (AllocationHeader*) headerAddress; headerPtr = &allocationHeader;

Which doesn't copy the AllocationHeader object that's created on the stack into the memory position.

You should either use

memcpy(headerAddress, &allocationHeader, sizeof(AllocationHeader))

or just use placement new operator to create the object at the memory location.

I've tested this and just as I expected, you're actually getting garbage when you're reading the header in the Free function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions