INN commit: trunk/tests (runtests.c)
INN Commit
rra at isc.org
Fri Aug 28 19:12:02 UTC 2015
Date: Friday, August 28, 2015 @ 12:12:02
Author: iulius
Revision: 9931
Update to latest C TAP Harness release 3.4
Fix segfault in runtests with empty test list.
Modified:
trunk/tests/runtests.c
------------+
runtests.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
Modified: runtests.c
===================================================================
--- runtests.c 2015-08-10 11:51:03 UTC (rev 9930)
+++ runtests.c 2015-08-28 19:12:02 UTC (rev 9931)
@@ -1205,7 +1205,8 @@
/*
* Read a list of tests from a file, returning the list of tests as a struct
- * testlist. Reports an error to standard error and exits if the list of
+ * testlist, or NULL if there were no tests (such as a file containing only
+ * comments). Reports an error to standard error and exits if the list of
* tests cannot be read.
*/
static struct testlist *
@@ -1259,6 +1260,12 @@
}
fclose(file);
+ /* If there were no tests, current is still NULL. */
+ if (current == NULL) {
+ free(listhead);
+ return NULL;
+ }
+
/* Return the results. */
return listhead;
}
@@ -1267,7 +1274,8 @@
/*
* Build a list of tests from command line arguments. Takes the argv and argc
* representing the command line arguments and returns a newly allocated test
- * list. The caller is responsible for freeing.
+ * list, or NULL if there were no tests. The caller is responsible for
+ * freeing.
*/
static struct testlist *
build_test_list(char *argv[], int argc)
@@ -1292,6 +1300,12 @@
current->ts->file = xstrdup(argv[i]);
}
+ /* If there were no tests, current is still NULL. */
+ if (current == NULL) {
+ free(listhead);
+ return NULL;
+ }
+
/* Return the results. */
return listhead;
}
More information about the inn-committers
mailing list