What steps will reproduce the problem?
1. Compile version 1.6 using Visual Studio 2008
2. Create a simple main.cpp program as follows:
#include <gflags/gflags.h>
int main(int argc, char* argv[])
{
google::ParseCommandLineFlags(&argc, &argv, true);
return 0;
}
3. Run it with "--help" as the argument.
What is the expected output? What do you see instead?
It will blow up on the first assert in
gflags_reporting.cc:DescribeOneFlag(const CommandLineFlagInfo& flag).
This is because the flag.description is truncated in SStringPrintf, since the
util.h:InternalStringPrintf() contains a bug.
Basically the space[128] buffer is reused wrongly in the second loop, which
tries to reformat the string with a bigger buffer. Instead of using
vsnprintf(buf, length, ...)
it is
vsnprintf(space, length, ...)
Which uses the wrong buffer.
What version of the product are you using? On what operating system?
This bug should be present on most platforms as far as I can tell from the
code. Basically, it will currently blow up when running "--help" where the
description is longer than 128 bytes.
Please provide any additional information below.
A patch is attached.
Original issue reported on code.google.com by cyberm...@gmail.com on 16 Aug 2011 at 12:12
Original issue reported on code.google.com by
cyberm...@gmail.com
on 16 Aug 2011 at 12:12Attachments: