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

Re: PATCH: Fix use-after-free for print -zf and print -sf



On Tue, 10 Feb 2015 08:16:56 +0100
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> On Tue, Feb 10, 2015 at 8:12 AM, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> >      /* Testing EBADF special-cases >&- redirections */
> > -    if ((fout != stdout) ? (fclose(fout) != 0) :
> > +    if (fout && (fout != stdout) ? (fclose(fout) != 0) :
> 
> Do I need an extra set of parens here? C precedence rules are fun.
> 

https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Operator_precedence

"&&" is higher precedence than && so this looks OK.

I suppose it's at the point where a lot of people would decide it needed
expanding into something clearer, but it's a reasonable extension of
what was there before.  Can't see a problem with it.

pws



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