Fix segfault reported by jonmay (#12)