Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: fc resource leak
- X-seq: zsh-workers 26028
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxxxxx>
- Subject: PATCH: fc resource leak
- Date: Wed, 12 Nov 2008 11:31:57 +0100
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=Received:X-YMail-OSG:X-Yahoo-Newman-Property:Received:From:To:Subject:Date:Message-ID; b=30GsK1/TTIlVVIc9mLHxqf3+Njpm98tICX9j7rEhhCTB8UMZUzXVXI80ir9OYozVILGBISoFOw534atGM/s9louCdP4ISfuoqA6AUe8jbjCZLZkhKxifenrcMNlh5KNGPFNYwjSZrn6ftZc0/+lK+kGQwD1JMn32Yg2VSIiDmZc= ;
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
CID 128. In this case, a temporary file is not being closed when an
error condition occurs. Even though the file is deleted, it is still open.
Doing ls -l /proc/$$/fd on Linux makes it easy to see the open deleted
files. Running fc with the current event number prints a message to warn
about "current history line would recurse endlessly, aborted". Coverity
doesn't notice it but the same problem applies to two further error
messages down in the fclist() function.
Oliver
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.217
diff -u -r1.217 builtin.c
--- Src/builtin.c 5 Nov 2008 13:02:09 -0000 1.217
+++ Src/builtin.c 12 Nov 2008 10:23:53 -0000
@@ -1480,6 +1480,7 @@
unqueue_signals();
zwarnnam("fc",
"current history line would recurse endlessly, aborted");
+ fclose(out);
unlink(fil);
return 1;
}
@@ -1619,6 +1620,8 @@
zwarnnam("fc", "no such event: %s", buf);
} else
zwarnnam("fc", "no events in that range");
+ if (f != stdout)
+ fclose(f);
return 1;
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author