Fix bugs in HW renderer found by Coverity scan