Fixed bugs found by coverty-scan (memory leak, possible illegal memory access, uninitialized members, unreachable code).