Fix some scan coverity reports

I tried to fix some coverity reports (those I assigned + fix required)
I triaged 1031979 and 1032467, if someone can take a look to comments associated.