]> git.ozlabs.org Git - ccan/commitdiff
ccanlint: protect against the function element in the doc section being null
authorBrad Hards <bradh@frogmouth.net>
Wed, 19 Jan 2011 06:03:32 +0000 (17:03 +1100)
committerRusty Russell <rusty@rustcorp.com.au>
Sat, 22 Jan 2011 02:04:27 +0000 (12:34 +1030)
This can happen if the documentation doesn't have a properly formatted summary line,
and it causes the examples_relevant test to segfault.

tools/ccanlint/tests/examples_relevant.c

index 283e78c10cda3914ce3ccaaad328c31be94d5f89..66dee27e65c427cc91bd4f67a5a7e1b04fe7f292 100644 (file)
@@ -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;