Plan A mmap()'s the entire input file and operates on it in memory. The mmap(2) call succeeded, so we shouldn't need to bother checking for the NUL byte as long as we're within our buffer space.
Admittedly, I don't know what the "behavior of the original code" is that this is trying to maintain, but this actively broke patching of net/rubygem-grpc at the very least. If this is wrong, I have an alternative patch to make this fallback to plan B, but I don't see any reason for this NUL check.
I will be requested an exp-run for this, but a couple of test patches using plan A worked just fine.