Fix some small type issues in printf formats
Fix 2 unlikely memory leaks
Fasten utils_tidy_path() a little and fix possible leaks in it

Fix possible leaks with bad paths, and also speed up some part of the
function by avoiding unnecessary allocations and string length
computations.