Fix SEGV from #996