[PATCH 2/2] vshReadlineInit: Initialize only once

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



'vshReadlineInit' is called when interactive virsh is started but also
on each call to 'cmdComplete'. Calling it repeatedly (using the
'complete' command interactively, or multiple times in batch mode) leaks
the buffers for history file configuration.

Avoid multiple setups of this function by returning success in case the
history file config is already present.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tools/vsh.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/vsh.c b/tools/vsh.c
index 05de54b5b0..f954f7af77 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -2908,6 +2908,10 @@ vshReadlineInit(vshControl *ctl)
     const char *break_characters = " \t\n`@$><=;|&{(";
     const char *quote_characters = "\"'";

+    /* initialize readline stuff only once */
+    if (ctl->historydir)
+        return 0;
+
     /* Opaque data for autocomplete callbacks. */
     autoCompleteOpaque = ctl;

-- 
2.44.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux