fix non-empty buffers
authorRichard Russon <rich@flatcap.org>
Thu, 14 Jun 2018 18:12:33 +0000 (19:12 +0100)
committerRichard Russon <rich@flatcap.org>
Thu, 14 Jun 2018 18:46:51 +0000 (19:46 +0100)
Insert a few `mutt_buffer_reset()`s.

Commit 9d6a2418 replaced a lot of `snprintf()`s with `mutt_buffer_printf()`.
Unfortunately, a few of the original lines were relying on `snprintf()`
writing over the beginning of the buffer.

hook.c
init.c

diff --git a/hook.c b/hook.c
index 8b5243d66f69afac5f60f80a299e720a04913514..2a63009f10f3ea7e578f7f52dc11e32a7bb79664 100644 (file)
--- a/hook.c
+++ b/hook.c
@@ -686,6 +686,7 @@ void mutt_timeout_hook(void)
     if (mutt_parse_rc_line(hook->command, &token, &err) == -1)
     {
       mutt_error("%s", err.data);
+      mutt_buffer_reset(&err);
 
       /* The hooks should be independent of each other, so even though this on
        * failed, we'll carry on with the others. */
@@ -720,6 +721,7 @@ void mutt_startup_shutdown_hook(int type)
     if (mutt_parse_rc_line(hook->command, &token, &err) == -1)
     {
       mutt_error("%s", err.data);
+      mutt_buffer_reset(&err);
     }
   }
   FREE(&token.data);
diff --git a/init.c b/init.c
index c2cb746e955d3849b8696d486e1de04d5856c404..8e061150f84827889880b712e15bb94e3c4a4475 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1309,6 +1309,7 @@ static int source_rc(const char *rcfile_path, struct Buffer *err)
   if (rc)
   {
     /* the neomuttrc source keyword */
+    mutt_buffer_reset(err);
     mutt_buffer_printf(err, (rc >= -MAXERRS) ? _("source: errors in %s") : _("source: reading aborted due to too many errors in %s"),
                        rcfile);
     rc = -1;
@@ -2004,6 +2005,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data,
     /* get the variable name */
     mutt_extract_token(buf, s, MUTT_TOKEN_EQUAL);
 
+    mutt_buffer_reset(err);
     if (mutt_str_strncmp("my_", buf->data, 3) == 0)
       myvar = buf->data;
     else if ((idx = mutt_option_index(buf->data)) == -1 &&