[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.
In the previous version maximum checked number was ```last_index - 1``` because ```i < rv.size```.
And this condition can be simplified because ```last_index = end - start``` so we can check ```end - 1 > LONG_MAX```. ```end - 1``` is the biggest value of ```lnum``` in the loop.
I'm not sure that such check can be true because ```end``` is ```int64_t```. Maybe we don't need it at all?