Fix segfault related to checking return value of opendi