diff --git a/examples/ti/ek-tm4c1294xl-baremetal/syscalls.c b/examples/ti/ek-tm4c1294xl-baremetal/syscalls.c index 49312476..ff2a9a2e 100644 --- a/examples/ti/ek-tm4c1294xl-baremetal/syscalls.c +++ b/examples/ti/ek-tm4c1294xl-baremetal/syscalls.c @@ -12,8 +12,11 @@ void *_sbrk(int incr) { extern char _end; static unsigned char *heap = NULL; unsigned char *prev_heap; + unsigned char x = 0, *heap_end = (unsigned char *)((size_t) &x - 512); + (void) x; if (heap == NULL) heap = (unsigned char *) &_end; prev_heap = heap; + if (heap + incr > heap_end) return (void *) -1; heap += incr; return prev_heap; }