// NOTE: the wxWindow event handler list is always terminated with "this" handler
wxEvtHandler *handlerCur = GetEventHandler()->GetNextHandler();
- while ( handlerCur != this )
+ while ( handlerCur != this && handlerCur )
{
wxEvtHandler *handlerNext = handlerCur->GetNextHandler();