bug-bash
[Top][All Lists]
Advanced

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

memory leak in case of "read -e"


From: ZhangXiao
Subject: memory leak in case of "read -e"
Date: Wed, 22 Feb 2017 15:33:00 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1

Hi Chet and experts,

Build in command "read" with "-e" option causes memory leak. Can be
reproduced with below script and lots of input data.

$cat script.sh
#!/bin/bash/bash
while [ 1 ];
do
        read -e data;
        echo $data;
done
$./script.sh


The patch at the end of this mail can fix it.

Thanks
Xiao

diff --git a/builtins/read.def b/builtins/read.def
index 33821f3..60bdc87 100644
--- a/builtins/read.def
+++ b/builtins/read.def
@@ -690,6 +690,11 @@ add_char:
   input_string[i] = '\0';
   CHECK_ALRM;

+#if defined (READLINE)
+  if (edit)
+    xfree (rlbuf);
+#endif
+
   if (retval < 0)
     {
       t_errno = errno;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]