diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 35a59710c05e..b5c63ec98de6 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -3746,9 +3746,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 @@ -3768,9 +3769,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: