Skip to content

Fix initial capacity of emitter #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Krotki
Copy link

@Krotki Krotki commented May 14, 2025

When you use tb_out_reserve right away after emitter creation with byte count > 64, it will allocate only 64 bytes and set capacity of to 64.

In elf64.c file we see:

    TB_Emitter strtbl = { 0 };
    tb_out_reserve(&strtbl, 1024); // strtbl will have 64 capacity
    tb_out1b(&strtbl, 0);

with latter usage of tb_out_*_UNSAFE results in overwrite of random memory ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant