diff: avoid applying offsets to null pointer
This was the only instance of undefined behavior I could find so far.