Be careful of integer overflows when allocating buffer storage