Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: File descriptor leakage?



On Mon, Sep 29, 2014 at 11:59:01AM +0100, Peter Stephenson wrote:
> [...]
>
> Hmm, that's to do with file locking.  That might suggest some path
> through the code where this isn't handled that neither Bart nor I have
> spotted yet.
> 
> diff --git a/Src/hist.c b/Src/hist.c
> index d29a65a..4660fd0 100644
> --- a/Src/hist.c
> +++ b/Src/hist.c
> @@ -2593,7 +2593,12 @@ savehistfile(char *fn, int err, int writeflags)
>  		out = NULL;
>  	    } else {
>  		int fd = open(tmpfile, O_CREAT | O_WRONLY | O_EXCL, 0600);
> -		out = fd >= 0 ? fdopen(fd, "w") : NULL;
> +		if (fd >=0) {
> +		    out = fdopen(fd, "w");
> +		    if (!out)
> +			close(fd);
> +		} else
> +		    out = NULL;
>  	    }
>  
>  #ifdef HAVE_FCHMOD
>

Hi, I'm sorry I didn't test master. It turns out that this has already
been fix at commit 4414e54ea7ffe50acca851c11c2ef49dc867c55d. And the
patch above doesn't fix it for me (patched against that bad commit).

-- 
Best regards,
lilydjwg



Messages sorted by: Reverse Date, Date, Thread, Author