fix mutable default arg bug in safe_walk; fixup to #4751

This is exactly why mutable default argument values are evil.
Fixup to #4751.