Code fixes

Various code fixes, mostly discovered by MSVC code static analyzer .
`index + col-1` is used in condition. The same must be used in assignment. Notice `col++;` and code at https://github.com/xbmc/xbmc/pull/5045/files#diff-879fccbcc34e4653aa7e8b676e0c9600R1533