Fix refcounting / lock race.

Reported by Steve Wilkins / Michel Dänzer.
1 file changed