[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.
Your comment intimated that former version has a bug: if ```end == LONG_MAX``` and ```start < 0``` for example then ```end - start``` will cause overflow. Perhaps we should add check for that because these values come from plugins.