Fix some abuses of StringRef

We were taking a StringRef to a temporary result, which can go horribly wrong.