google / fuzztest

Other
692 stars 67 forks source link

Fix source code generation for byte vectors. #1327

Closed copybara-service[bot] closed 4 weeks ago

copybara-service[bot] commented 4 weeks ago

Fix source code generation for byte vectors.

Previously we generated the following regression test source code:

fuzztest::ToByteArray("\0abc")

which was incorrect as it creates a zero length byte array as opposed to a 4 length one. The problem is that the passed string constant will be a const char*, which is handled as a C-string. C-strings are \0 terminated and thus parsing stops when it reaches the \0 character. With this fix we generate the following:

fuzztest::ToByteArray(std::string("\0abc",4))