patch: don't run off the end of path if it ends in '/'.
Found by fuzzing (afl) in OpenBSD.
Obtained from: OpenBSD (CVS 1.65)