Check return value.

Fixes CID #1109591, #1084350
Fix uninitialized class members.

Fixes CID #966364, #966344, #966315, #966315, #966347, #966319, #966314,
 #966313, #966280