On Saturday, 9 September 2023 at 09:56:59 UTC, H. S. Teoh wrote:
libc doesn't know what you intended. All it knows is that you
asked it for 20 bytes (even though you actually needed 40),
then later on its internal structures are corrupted (because
you thought you got 40 bytes; storing data past the 20 bytes
overwrote some of malloc's internal data -- this is the buffer
overrun / buffer overflow I referred to). So it aborts the
program instead of continuing to run in a compromised state.
T
Thank you! I fully realize now what's the problem! And that was
indeed a very sneaky problem. The good news is that I'm mostly
done with these memory structures and functions so I will
probably take a while since I find something similar.
I'm lucky there are people smarter, more experience that are
willing to help. Bless you all and have a great day!