]> granicus.if.org Git - mutt/commitdiff
Fix a possible segmentation fault with the external query feature.
authorThomas Roessler <roessler@does-not-exist.org>
Sat, 29 Apr 2000 13:38:05 +0000 (13:38 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Sat, 29 Apr 2000 13:38:05 +0000 (13:38 +0000)
query.c

diff --git a/query.c b/query.c
index 439f71d0f603ff37278703219267243f217a239d..ad49746587b91dd828b27e3e8a254401e244add7 100644 (file)
--- 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;