Skip to content

Commit

Permalink
Fix segfault with default-constructed rosbag::ChunkedFile::swap
Browse files Browse the repository at this point in the history
Closes ros#2362.
  • Loading branch information
Hugal31 committed Nov 29, 2023
1 parent 845f746 commit e9d08d3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tools/rosbag_storage/src/chunked_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,16 @@ void ChunkedFile::swap(ChunkedFile& other) {
FileAccessor::setFile(*other.stream_factory_->getStream(compression::LZ4), &other);

swap(read_stream_, other.read_stream_);
FileAccessor::setFile(*read_stream_, this);
FileAccessor::setFile(*other.read_stream_, &other);
if (read_stream_)
FileAccessor::setFile(*read_stream_, this);
if (other.read_stream_)
FileAccessor::setFile(*other.read_stream_, &other);

swap(write_stream_, other.write_stream_);
FileAccessor::setFile(*write_stream_, this);
FileAccessor::setFile(*other.write_stream_, &other);
if (write_stream_)
FileAccessor::setFile(*write_stream_, this);
if (other.write_stream_)
FileAccessor::setFile(*other.write_stream_, &other);
}

} // namespace rosbag

0 comments on commit e9d08d3

Please sign in to comment.