Commit 531568a6 authored by Tudor Bosman's avatar Tudor Bosman Committed by Sara Golemon

fix segfault on fb platform

Summary: Strings can be moved around while the vector grows.

Test Plan: file_util_test

Reviewed By: lucian@fb.com

FB internal diff: D806966

Blame Revision: D806781
parent 63b61817
...@@ -192,9 +192,11 @@ IovecBuffers::IovecBuffers(std::initializer_list<size_t> sizes) { ...@@ -192,9 +192,11 @@ IovecBuffers::IovecBuffers(std::initializer_list<size_t> sizes) {
iov_.reserve(sizes.size()); iov_.reserve(sizes.size());
for (auto& s : sizes) { for (auto& s : sizes) {
buffers_.push_back(std::string(s, '\0')); buffers_.push_back(std::string(s, '\0'));
}
for (auto& b : buffers_) {
iovec iov; iovec iov;
iov.iov_base = &(buffers_.back()[0]); iov.iov_base = &b[0];
iov.iov_len = s; iov.iov_len = b.size();
iov_.push_back(iov); iov_.push_back(iov);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment