]> granicus.if.org Git - mutt/commitdiff
Convert parse_path_(un)list to use buffer pool for path.
authorKevin McCarthy <kevin@8t8.us>
Tue, 8 Oct 2019 05:07:40 +0000 (13:07 +0800)
committerKevin McCarthy <kevin@8t8.us>
Tue, 8 Oct 2019 05:07:40 +0000 (13:07 +0800)
Don't use the buf parameter to avoid stretching it out, as it's used
for the entire rc parsing, and typically just holds command names.

init.c

diff --git a/init.c b/init.c
index 621cd3c15e546099e077cac6fd40263f5af232a3..9938a99a28700bb3a2fd3eec421cadadb14e30dc 100644 (file)
--- a/init.c
+++ b/init.c
@@ -965,42 +965,44 @@ static int parse_unlist (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUF
 #ifdef USE_SIDEBAR
 static int parse_path_list (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err)
 {
-  char path[_POSIX_PATH_MAX];
+  BUFFER *path;
   LIST **data = udata.p;
 
+  path = mutt_buffer_pool_get ();
   do
   {
-    mutt_extract_token (buf, s, 0);
-    strfcpy (path, buf->data, sizeof (path));
-    mutt_expand_path (path, sizeof (path));
-    add_to_list (data, path);
+    mutt_extract_token (path, s, 0);
+    mutt_buffer_expand_path (path);
+    add_to_list (data, mutt_b2s (path));
   }
   while (MoreArgs (s));
+  mutt_buffer_pool_release (&path);
 
   return 0;
 }
 
 static int parse_path_unlist (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err)
 {
-  char path[_POSIX_PATH_MAX];
+  BUFFER *path;
   LIST **data = udata.p;
 
+  path = mutt_buffer_pool_get ();
   do
   {
-    mutt_extract_token (buf, s, 0);
+    mutt_extract_token (path, s, 0);
     /*
      * Check for deletion of entire list
      */
-    if (mutt_strcmp (buf->data, "*") == 0)
+    if (mutt_strcmp (mutt_b2s (path), "*") == 0)
     {
       mutt_free_list (data);
       break;
     }
-    strfcpy (path, buf->data, sizeof (path));
-    mutt_expand_path (path, sizeof (path));
-    remove_from_list (data, path);
+    mutt_buffer_expand_path (path);
+    remove_from_list (data, mutt_b2s (path));
   }
   while (MoreArgs (s));
+  mutt_buffer_pool_release (&path);
 
   return 0;
 }