Skip to content

Commit

Permalink
GH-15137: [C++][CI] Fix ASAN error in streaming JSON reader tests (#3…
Browse files Browse the repository at this point in the history
…3772)

The input streams passed to the reader weren't properly taking ownership of their test strings, despite the stream (potentially) outliving the test's scope.
* Closes: #15137

Authored-by: benibus <bpharks@gmx.com>
Signed-off-by: Antoine Pitrou <antoine@python.org>
  • Loading branch information
benibus committed Jan 19, 2023
1 parent a1a587b commit a4236ab
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cpp/src/arrow/json/reader_test.cc
Expand Up @@ -439,14 +439,14 @@ class StreamingReaderTestBase {
virtual ~StreamingReaderTestBase() = default;

protected:
static std::shared_ptr<io::InputStream> MakeTestStream(const std::string& str) {
auto buffer = std::make_shared<Buffer>(str);
static std::shared_ptr<io::InputStream> MakeTestStream(std::string str) {
auto buffer = Buffer::FromString(std::move(str));
return std::make_shared<io::BufferReader>(std::move(buffer));
}
// Stream with simulated latency
static std::shared_ptr<io::InputStream> MakeTestStream(const std::string& str,
static std::shared_ptr<io::InputStream> MakeTestStream(std::string str,
double latency) {
return std::make_shared<io::SlowInputStream>(MakeTestStream(str), latency);
return std::make_shared<io::SlowInputStream>(MakeTestStream(std::move(str)), latency);
}

Result<std::shared_ptr<StreamingReader>> MakeReader(
Expand Down

0 comments on commit a4236ab

Please sign in to comment.