Browse Source

ccanlint: protect against the function element in the doc section being null

This can happen if the documentation doesn't have a properly formatted summary line,
and it causes the examples_relevant test to segfault.
Brad Hards 15 years ago
parent
commit
020983311c
1 changed files with 5 additions and 0 deletions
  1. 5 0
      tools/ccanlint/tests/examples_relevant.c

+ 5 - 0
tools/ccanlint/tests/examples_relevant.c

@@ -30,6 +30,11 @@ static void examples_relevant_check(struct manifest *m,
 			if (!streq(d->type, "example"))
 				continue;
 
+			if (!d->function) {
+				score_file_error(score, f, d->srcline+1,
+						 "Function name not found in summary line");
+				continue;
+			}
 			for (i = 0; i < d->num_lines; i++) {
 				if (strstr(d->lines[i], d->function))
 					found = true;