There is at least one memory leak in the read builtin in bash-3.0. To demonstrate it, try this test case:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=173283#c10 There is a link to a file, nonblock.c, which you should compile like 'make nonblock'. Then run the short script to see the problem. The problem comes about when stdin has O_NONBLOCK set. Here is the fix: --- bash-3.0/builtins/read.def.read-memleak 2005-12-07 17:45:38.000000000 +0000 +++ bash-3.0/builtins/read.def 2005-12-07 17:45:39.000000000 +0000 @@ -461,6 +461,7 @@ if (retval < 0) { builtin_error (_("read error: %d: %s"), fd, strerror (errno)); + run_unwind_frame ("read_builtin"); return (EXECUTION_FAILURE); } #endif There is another suspicious place in that function where an xfree is notable by its absence: --- bash-3.0/builtins/read.def.read-memleak 2005-12-07 17:45:38.000000000 +0000 +++ bash-3.0/builtins/read.def 2005-12-07 18:00:26.000000000 +0000 @@ -508,7 +508,10 @@ var = find_or_make_array_variable (arrayname, 1); if (var == 0) - return EXECUTION_FAILURE; /* readonly or noassign */ + { + xfree (input_string); + return EXECUTION_FAILURE; /* readonly or noassign */ + } array_flush (array_cell (var)); alist = list_string (input_string, ifs_chars, 0); ..but I couldn't work out how to demonstrate this particular leak, if that's what it is. Tim. */ _______________________________________________ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash