Skip to content

Commit

Permalink
Update parser tests to include comments about heap-allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
cmazakas committed Dec 24, 2023
1 parent 2d8f53d commit af01a36
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/unit/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,12 @@ struct parser_test
if( ! BOOST_TEST(! ec.failed()) ||
! BOOST_TEST(pr->got_header()))
return;

// we use a heap-allocated std::string object because internally,
// parsers store copies of the provided buffers (which have view
// semantics)
// placing the object on the heap ensures reliable
// use-after-free errors are produced under sanitized builds
std::unique_ptr<std::string> ptmp(new std::string());
auto &tmp = *ptmp;
buffers::string_buffer sb(
Expand Down

0 comments on commit af01a36

Please sign in to comment.