Fix defects detected by Coverity Scan
Targeted CIDs: 155456, 155962, 346121, 346123, 346124, 346125, 346126, 346127, 346130, 346131, 346132, 346134, 346135, 346138, 346140, 346145, 346146, 346149, 346152, 346154, 346156, 346157
Edited by Vladimír Čunát