[RFC] Coverity Issues

This PR fixes several Coverity issues listed in #760 , namely 13796, 62607, 62608, 62609, 62612, 62615. Additionally I found that some of the Coverity defects are false positives, especially in the ressource leak category.

I couldn't find how to mark them as false positives in the Coverity web interface though. I suspect that my role of contributer doesn't have sufficient rights to do so.
Yes, I also would like to see the parameters verified at the start and return in case of error:
Here is what I would check for:
* Check if `new_len` <= LONG_MAX (otherwise new slice is to big)
* Check if `start,end` are in `{0,..,buf->b_ml.ml_line_count}` after "normalization" (otherwise invalid old slice)
* Check if `start <= end`
* Check if `buf->b_ml.ml_line_count + (new_len - old_len) <= LONG_MAX` (otherwise new slice is to big)

After that no range checks should be needed anymore.