refs: prevent accidental NULL dereference in write_pseudoref