coll/ml: fix leaks

Thanks to ggouaillardet for finding and fixing these issues.

Closes #4460

cmr=v1.8.1:reviewer=manjugv