copy_path produces one element too much
Running the attached c program gives me:
version 11600
M 100.000 100.000 L 100.000 300.000 L 300.000 300.000 L 300.000 100.000 Z M 100.000 100.000
The last M segment ist superfluous (copied from the beginning?).