AE: coverity changes

The second commit needs review by @Anssih

Thanks to cg110 via: http://forum.xbmc.org/showthread.php?tid=170338&pid=1660366#pid1660366