Add a !null assert

Found by coverity
Add a !null assert

Found by coverity
Add missing braces around a multiline block

Found by coverity
Add missing break

Found by coverity
Add missing break

Found by coverity
Don't increment an iterator if it's past the end

Found by coverity
Don't increment an iterator if it's past the end

Found by coverity