From: Thomas Roessler Date: Sat, 29 Apr 2000 13:38:05 +0000 (+0000) Subject: Fix a possible segmentation fault with the external query feature. X-Git-Tag: mutt-1-1-13-rel~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5218ba983fea53ce02189314e21679b8510ffc37;p=mutt Fix a possible segmentation fault with the external query feature. --- diff --git a/query.c b/query.c index 439f71d0..ad497465 100644 --- a/query.c +++ b/query.c @@ -92,21 +92,21 @@ static QUERY *run_query (char *s, int quiet) fgets (msg, sizeof (msg) - 1, fp); while (fgets(buf, sizeof (buf) - 1, fp)) { - if (first == NULL) - { - FirstColumn = 0; - SecondColumn = 0; - first = (QUERY *) safe_calloc (1, sizeof (QUERY)); - cur = first; - } - else - { - cur->next = (QUERY *) safe_calloc (1, sizeof (QUERY)); - cur = cur->next; - } - p = strtok(buf, "\t\n"); - if (p) + if ((p = strtok(buf, "\t\n"))) { + if (first == NULL) + { + FirstColumn = 0; + SecondColumn = 0; + first = (QUERY *) safe_calloc (1, sizeof (QUERY)); + cur = first; + } + else + { + cur->next = (QUERY *) safe_calloc (1, sizeof (QUERY)); + cur = cur->next; + } + l = mutt_strlen (p); if (l > SecondColumn) SecondColumn = l;