On Fri, Mar 04, 2022 at 06:16:28PM -0800, Kevin J. McCarthy wrote: > A slightly more intrusive patch using strchr() might be better (untested, > just below). This also removes '\n' from the delim list, since that's a > remnant from when fgets() was used. > > diff --git a/query.c b/query.c > index 5a5c07b0..d0617c23 100644 > --- a/query.c > +++ b/query.c > @@ -106,7 +106,7 @@ static QUERY *run_query (char *s, int quiet) > int dummy = 0; > char *msg = NULL; > size_t msglen; > - char *p; > + char *tok, *nexttok; > pid_t thepid; > cmd = mutt_buffer_pool_get (); > @@ -128,27 +128,35 @@ static QUERY *run_query (char *s, int quiet) > msg = mutt_read_line (msg, &msglen, fp, &dummy, 0); > while ((buf = mutt_read_line (buf, &buflen, fp, &dummy, 0)) != NULL) > { > - if ((p = strtok(buf, "\t\n"))) > + tok = buf; > + if ((nexttok = strchr (tok, '\t'))) > + *nexttok++ = 0; > + > + if (first == NULL) > { > - if (first == NULL) > - { > - first = (QUERY *) safe_calloc (1, sizeof (QUERY)); > - cur = first; > - } > - else > - { > - cur->next = (QUERY *) safe_calloc (1, sizeof (QUERY)); > - cur = cur->next; > - } > + first = (QUERY *) safe_calloc (1, sizeof (QUERY)); > + cur = first; > + } > + else > + { > + cur->next = (QUERY *) safe_calloc (1, sizeof (QUERY)); > + cur = cur->next; > + } > + > + cur->addr = rfc822_parse_adrlist (cur->addr, tok); > + if (nexttok) > + { > + tok = nexttok; > + if ((nexttok = strchr (tok, '\t'))) > + *nexttok++ = 0; > + cur->name = safe_strdup (tok); > - cur->addr = rfc822_parse_adrlist (cur->addr, p); > - p = strtok(NULL, "\t\n"); > - if (p) > + if (nexttok) > { > - cur->name = safe_strdup (p); > - p = strtok(NULL, "\t\n"); > - if (p) > - cur->other = safe_strdup (p); > + tok = nexttok; > + if ((nexttok = strchr (tok, '\t'))) > + *nexttok++ = 0; > + cur->other = safe_strdup (tok); > } > } > } > > > -- > Kevin J. McCarthy > GPG Fingerprint: 8975 A9B3 3AA3 7910 385C 5308 ADEF 7684 8031 6BDA
Could you please apply this patch? I have been using it for a month now and it seems to be stable and works great! Thanks.