diff options
author | Kevin McCarthy <kevin@8t8.us> | 2020-11-30 15:53:49 -0800 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2020-11-30 18:18:47 -0800 |
commit | f420be68d517268f5e8600bc01808c3ae4b5b6ba (patch) | |
tree | ab81b13ff8f4ea50b5f2ae3229bada9f4895a0fd /init.c | |
parent | cfdcfa7ffee69ecdf7a56a6b9c541d1f71496601 (diff) |
Ensure mutt_extract_token() never returns a NULL dest->data.
Commit e5a32a61 removed a 'mutt_buffer_addch (dest, 0)' at the end of
the function. Most callers had been converted to use the buffer pool,
and the call was strange since buffers self-terminate.
However, this line covered up logic errors in some of the callers,
which assumed the buffer->data could not be NULL afterwards.
I will try to fix up callers with the logic errors in master. This is
to fix the problem in stable, and also ensure future callers don't
make the same mistake.
Diffstat (limited to 'init.c')
-rw-r--r-- | init.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -141,6 +141,12 @@ int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags) char qc = 0; /* quote char */ char *pc; + /* Some callers used to rely on the (bad) assumption that dest->data + * would be non-NULL after calling this function. Perhaps I've missed + * a few cases, or a future caller might make the same mistake. + */ + if (!dest->data) + mutt_buffer_increase_size (dest, STRING); mutt_buffer_clear (dest); SKIPWS (tok->dptr); |