add assert for possible segfault

like it happened in https://gna.org/bugs/?22410