Rebased diff on trunk.
OK, thanks, I've updated the pull request. The imprecisely named copy_from_tempfile actually moves the tempfile, so there's no need to try to delete it. Of course, tempfile isn't freed there as it can't modify it. One solution is to modify copy_from_tempfile to take char **src, but it's much less disruptive to just leave out the cleanup_tempfile out for that invocation and leave a comment to say so.
Er... I'm so sorry it's been so long(!) The CI=0 flag change did indeed fix it for me, thank you...
Stop littering /tmp (and now source directory!) with ecp.* files