diff --git a/RTCP/Cobalt/CoInterface/src/Allocator.cc b/RTCP/Cobalt/CoInterface/src/Allocator.cc index ba185a4b90a91d22c2f1cc329127cfb7acb4bb5f..a6b80b9a1d7f8b28f812a2103fa353039df5c72e 100644 --- a/RTCP/Cobalt/CoInterface/src/Allocator.cc +++ b/RTCP/Cobalt/CoInterface/src/Allocator.cc @@ -124,6 +124,11 @@ namespace LOFAR for (SparseSet<void *>::const_iterator it = freeList.getRanges().begin(); it != freeList.getRanges().end(); it++) { void *begin = align(it->begin, alignment); + if ((char *) begin >= (char *) it->end ) { + // alignment shift already results in out of bounds + continue; + } + if ((char *) it->end - (char *) begin >= (ptrdiff_t) size) { // enough space -- reserve it freeList.exclude(begin, (void *) ((char *) begin + size));