fixed bug in cp.c that resulted in out-of-memory error