scan-build bugfixes

Probably not fixed in the optimal way but more of a premium issue report ;)