fix the segfault in #827