summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2013-07-25 09:45:33 +0100
committerPeter Stephenson <pws@zsh.org>2013-07-25 09:45:33 +0100
commit4095e175b6dcdaf901e783752bbd5a503c27881b (patch)
tree3d90acf4caf8bf53e24781310b3acac4bf9e89bd
parent673760876c767c25bcfce74915e1f0ffbfc88437 (diff)
downloadzsh-4095e175b6dcdaf901e783752bbd5a503c27881b.tar.gz
zsh-4095e175b6dcdaf901e783752bbd5a503c27881b.tar.xz
zsh-4095e175b6dcdaf901e783752bbd5a503c27881b.zip
31574: alternative fix for bad fd if no FD_CLOEXEC.
Remove dump records more consistently in that case.
-rw-r--r--ChangeLog5
-rw-r--r--Src/parse.c24
2 files changed, 21 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 6cd6659ba..913585d06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-07-25  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* 31574: Src/parse.c: alternative fix to 31545 if FD_CLOEXEC is
+	not available, removing dump records more consistently.
+
 2013-07-24  Richard Hartmann  <richih.mailinglist@gmail.com>
 
 	* 31571: Completion/Unix/Command/_vcsh: Update
diff --git a/Src/parse.c b/Src/parse.c
index b670925de..0c2a45833 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -3418,6 +3418,16 @@ incrdumpcount(FuncDump f)
     f->count++;
 }
 
+/**/
+static void
+freedump(FuncDump f)
+{
+    munmap((void *) f->addr, f->len);
+    zclose(f->fd);
+    zsfree(f->filename);
+    zfree(f, sizeof(*f));
+}
+
 /* Decrement the reference counter for a dump file. If zero, unmap the file. */
 
 /**/
@@ -3434,10 +3444,7 @@ decrdumpcount(FuncDump f)
 		q->next = p->next;
 	    else
 		dumps = p->next;
-	    munmap((void *) f->addr, f->len);
-	    zclose(f->fd);
-	    zsfree(f->filename);
-	    zfree(f, sizeof(*f));
+	    freedump(f);
 	}
     }
 }
@@ -3447,10 +3454,11 @@ decrdumpcount(FuncDump f)
 mod_export void
 closedumps(void)
 {
-    FuncDump p;
-
-    for (p = dumps; p; p = p->next)
-	zclose(p->fd);
+    while (dumps) {
+	FuncDump p = dumps->next;
+	freedump(dumps);
+	dumps = p;
+    }
 }
 #endif