ash: fix a memory leak
authorJon Tollefson <kniht@linux.vnet.ibm.com>
Tue, 13 Nov 2012 18:26:53 +0000 (19:26 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 13 Nov 2012 18:26:53 +0000 (19:26 +0100)
The script which triggers the leak:

while true
  do
    while true
      do
        break;
    done</dev/null
done

Signed-off-by: Jon Tollefson <kniht@linux.vnet.ibm.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c

index 010924db4a0db30cd80f9352fc28a80e0f233b9f..dda18e8b55283207a3523a2140c42ab5827072c5 100644 (file)
@@ -8676,6 +8676,8 @@ expredir(union node *n)
 #if ENABLE_ASH_BASH_COMPAT
  store_expfname:
 #endif
+                       if (redir->nfile.expfname)
+                               stunalloc(redir->nfile.expfname);
                        redir->nfile.expfname = fn.list->text;
                        break;
                case NFROMFD: