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

Bug in zsh 4.0.7



Hi,
  There is a bug in Src/math.c of zsh 4.0.7, line 382.  It is:

yyval.u.l = zstrtol(++ptr, &ptr, lastbase = 16);

The issue is that it's unspecified whether ++ptr or &ptr happens first.
Strictly speaking according to the C standard this results in undefined
behavior but in practice it means you may be taking the wrong address
(it may take the address of the pointer to 'X' or 'x', instead of the
address of the pointer one beyond 'X' or 'x').

The presumed fix would be:
ptr++;
yyval.u.l = zstrtol(ptr, &ptr, lastbase = 16);

References are C99 6.5p2 and C90 6.3p2.

Chris



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