Specify both len and cap when allocating. Fix MB-12230.