make numberOfThreeBitSectionsInCode() robust against overflowing buffers if length is known