Fix Issue 13367 - Buffer overflow when setting PATH

Fixup for pull #2332.