Commit a4153d5b903b1fe20edad776a6d0ec3c3cbcc0aa

Stefan Sperling 2020-12-17T23:13:10

more concise fix for path_list_reverse_input() crash; suggested by millert

diff --git a/regress/path/path_test.c b/regress/path/path_test.c
index 231a647..cb17e05 100644
--- a/regress/path/path_test.c
+++ b/regress/path/path_test.c
@@ -178,19 +178,14 @@ path_list_reverse_input(void)
 	size_t i;
 
 	TAILQ_INIT(&paths);
-	for (i = nitems(path_list_input) - 1; i > 0; i--) {
-		err = got_pathlist_insert(NULL, &paths, path_list_input[i],
+	for (i = nitems(path_list_input); i > 0;) {
+		err = got_pathlist_insert(NULL, &paths, path_list_input[--i],
 		    NULL);
 		if (err) {
 			test_printf("%s\n", __func__, err->msg);
 			return 0;
 		}
 	}
-	err = got_pathlist_insert(NULL, &paths, path_list_input[0], NULL);
-	if (err) {
-		test_printf("%s\n", __func__, err->msg);
-		return 0;
-	}
 
 	i = 0;
 	TAILQ_FOREACH(pe, &paths, entry) {