google / szl

A compiler and runtime for the Sawzall language
Other
69 stars 16 forks source link

[PATCH] '--intflag=' recognized as '--intflag=0' #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In ProcessCommandLineArguments, strtol's endptr is checked for '\0' to make 
sure the integer parsing didn't end on an error, but it doesn't check the 
corner case that the string is entirely empty.  Empty-string is not an integer.

On some platforms, errno is set to a nonzero value when this happens, but if 
you want to rely on that, why use endptr at all?

The patch fixes it by entering the error branch if the value is the empty 
string.

Original issue reported on code.google.com by aecolley on 13 Nov 2010 at 2:12

Attachments:

GoogleCodeExporter commented 9 years ago
Yep, the empty string shouldn't be silently turned into a numeric 0, and doing 
so also diverges from gflags behavior.  Should be fixed as of r40.

Original comment by dbh@google.com on 14 Nov 2010 at 11:10

GoogleCodeExporter commented 9 years ago

Original comment by dbh@google.com on 16 Nov 2010 at 7:45