extra checking on memory allocation sizes to prevent a class of overflow attacks