attrcache: fix use-after-free

Reported by coverity.