Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined std::vector access in Bag::readRecords #55

Open
kya8 opened this issue Jul 12, 2023 · 0 comments
Open

Undefined std::vector access in Bag::readRecords #55

kya8 opened this issue Jul 12, 2023 · 0 comments

Comments

@kya8
Copy link

kya8 commented Jul 12, 2023

embag/lib/embag.cc

Lines 168 to 169 in 74c0b5f

chunk_infos_.reserve(chunk_count);
chunks_.reserve(chunk_count);

Both chunk_infos_ and chunks_ were reserve()'d, then accessed without initializing, which is undefined.

For chunk_infos_:

chunk_infos_[i] = chunk_info;

And &chunks_[i] was accessed before the element was pushed:

embag/lib/embag.cc

Lines 288 to 296 in 74c0b5f

index_block.into_chunk = &chunks_[i];
info.message_count += msg_count;
connections_[connection_id].blocks.push_back(index_block);
connections_[connection_id].data.message_count += msg_count;
}
chunk.info = info;
chunks_.push_back(chunk);

It does happen to work on MSVC Release build, but a "vector subscription out of range" exception was emitted in Debug build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant