From: Brad Hards Date: Wed, 19 Jan 2011 06:03:32 +0000 (+1100) Subject: ccanlint: protect against the function element in the doc section being null X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=020983311c9f58bee8d528f80c7c097c4405975c 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. --- diff --git a/tools/ccanlint/tests/examples_relevant.c b/tools/ccanlint/tests/examples_relevant.c index 283e78c1..66dee27e 100644 --- a/tools/ccanlint/tests/examples_relevant.c +++ b/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;