Fix segmentation fault when xdf_fdopen fails