When the argument for char-after is a marker, the function gets bytepos from the buffer the marker is pointing to by calling marker_byte_position. But then pos_byte is compared to BEGV_BYTE and ZV_BYTE that use the current buffer. At the end of the function, pos_byte is passed to FETCH_CHAR, which also operates on the current buffer.