get_bits: introduce safe bitreading to prevent overreads.