diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index a8c3aedc03..87cb28ef89 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -3764,9 +3764,10 @@ zpool_do_import(int argc, char **argv) return (1); } - err = import_pools(pools, props, mntopts, flags, argv[0], - argc == 1 ? NULL : argv[1], do_destroyed, pool_specified, - do_all, &idata); + err = import_pools(pools, props, mntopts, flags, + argc >= 1 ? argv[0] : NULL, + argc >= 2 ? argv[1] : NULL, + do_destroyed, pool_specified, do_all, &idata); /* * If we're using the cachefile and we failed to import, then @@ -3786,9 +3787,10 @@ zpool_do_import(int argc, char **argv) nvlist_free(pools); pools = zpool_search_import(g_zfs, &idata, &libzfs_config_ops); - err = import_pools(pools, props, mntopts, flags, argv[0], - argc == 1 ? NULL : argv[1], do_destroyed, pool_specified, - do_all, &idata); + err = import_pools(pools, props, mntopts, flags, + argc >= 1 ? argv[0] : NULL, + argc >= 2 ? argv[1] : NULL, + do_destroyed, pool_specified, do_all, &idata); } error: