Fix #845 - memory leaks in function filter_refline