BUG: fix segfault introduced by prior #2981 fix