Fix some potential NULL-dereferences

This commit fixes some (potential) bugs found by the clang-analyzer
scan-build tool.

Change-Id: Ia9b2250ab9417ab278e2d0b565cdc79823ccaa12
Closes: #10
See: https://github.com/Incubaid/crakoon/issues/10