diff: fix a possible null pointer dereference