Fixed a crash reported by Martin Bähr.