Fixed crash in TermBuffer.

Thanks to Artem Goussev.