Skip to content

Commit

Permalink
Fixed corrupted messages when reopening a rosbag with a different file
Browse files Browse the repository at this point in the history
* Bag::decompressed_chunk_ was not reset in close(). decompressed_chunk_
stores the offset (within the file) of the compressed chunk whose
decompressed content is currently stored in decompress_buffer_. Since it
wasn't reset in close(), if the offset is the same as that of the first
chunk in the file opened next, Bag::decompressChunk() assumed that
it had already decompressed that chunk in the new file and just returned.
As a result, some member functions of Bag worked on the decompressed
chunk of the old bag.
* Cleaned up more state in Bag::close() and ChunkedFile::close()
  • Loading branch information
racko committed Oct 21, 2017
1 parent 716422c commit abb8491
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/rosbag_storage/src/bag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ void Bag::close() {
chunks_.clear();
connection_indexes_.clear();
curr_chunk_connection_indexes_.clear();

init();
}

void Bag::closeWrite() {
Expand Down
2 changes: 2 additions & 0 deletions tools/rosbag_storage/src/chunked_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ void ChunkedFile::close() {
filename_.clear();

clearUnused();
offset_ = 0;
compressed_in_ = 0;
}

// Read/write modes
Expand Down

0 comments on commit abb8491

Please sign in to comment.