Adds small validation for free (freeing out of upper bound) and adds task to readme.md

This commit is contained in:
Felix Queissner 2015-08-18 15:06:49 +02:00
parent 19c75d5fe9
commit e6d4e0a41a
3 changed files with 5 additions and 2 deletions

View file

@ -13,7 +13,7 @@ Also it leaks memory. A lot of memory.
- Adding support for Modules
- Adding support for Pointer Types
- Adding support for String Type
- Implement custom malloc that does what it should
- Changing malloc magic number to hash value for complete validation.
## Guidlines
- Calls to `die` or `die_extra` should follow the following scheme: `ContextName.ErrorName`

View file

@ -3,7 +3,7 @@ VAR global : INT;
PUB main() | i : INT
BEGIN
0 -> i;
WHILE ((i + 1) -> i) <= 50 DO
WHILE ((i + 1) -> i) <= 25 DO
BEGIN
print2Int(50 - i, i);
sleep(2);

View file

@ -202,6 +202,9 @@ void free(void *ptr)
if((uintptr_t)ptr < (uintptr_t)malloc_heap_start) {
die_extra("free.InvalidFree", itoa((int)ptr, nullptr, 16));
}
if((uintptr_t)ptr >= (uintptr_t)malloc_heap_end) {
die_extra("free.InvalidFree", itoa((int)ptr, nullptr, 16));
}
freeCount++;
List *entry = (List*)((char*)ptr - sizeof(List));