Be more defensive and check for NULL pointer where is should not be.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Handle errors better in functions suppress_error_output() and restore_error_output().

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>