diff options
| author | Christian Walther <cwalther@gmx.ch> | 2020-09-28 22:34:02 +0200 |
|---|---|---|
| committer | Christian Walther <cwalther@gmx.ch> | 2020-10-02 23:03:21 +0200 |
| commit | d6d02c67d2bcacaa02499930aabd76365797b108 (patch) | |
| tree | 74f22d3a0579f76aaa6c13100875d7a9c4070a8e /py/persistentcode.c | |
| parent | 551f78e10b42d7aef97921f432d2af3a9843076a (diff) | |
Fix inconsistent supervisor heap.
When allocations were freed in a different order from the reverse of how they were allocated (leaving holes), the heap would get into an inconsistent state, eventually resulting in crashes.
free_memory() relies on having allocations in order, but allocate_memory() did not guarantee that: It reused the first allocation with a NULL ptr without ensuring that it was between low_address and high_address. When it belongs to a hole in the allocated memory, such an allocation is not really free for reuse, because free_memory() still needs its length.
Instead, explicitly mark allocations available for reuse with a special (invalid) value in the length field. Only allocations that lie between low_address and high_address are marked that way.
Diffstat (limited to 'py/persistentcode.c')
0 files changed, 0 insertions, 0 deletions
