Hello Alan,
Your changes indeed help.
Still it happens emacs completely hangs when isearching. So I do not really agree the bug is fixed.
I can (but not really allowed to) send you the cpp file which causes trouble. If you agree to not distribute it?
Regards,
Toon