check for NULL in sxi_*_cleanup
fix memory leak in dctx_free