Fix crash in on_text processing