The ecases_remove_by_expi() function in expect.c uses memcpy() to shift elements down. The areas can be overlapping. When they are, the construct is non-portable and can lead to memory corruption.
Please replace the memcpy call with a memmove call. That fixes the issue.
This is a real problem. It causes expect to randomly crash when run on the LysKOM server testsuite on an x86_64 Linux system (Ubuntu 13.04, gcc 4.7.3). valgrind helped me track down the issue.
(The issue can be reproduced by running the test suite of https://git.lysator.liu.se/lyskom-server/lyskom-server. Be sure to instrument runtest so that it uses valgrind to invoce expect.)