name-rev: avoid leaking memory in the `deref` case