Summary:
The following asserts:
fbstring str(1337, 'f');
fbstring cp = str;
cp.push_back('f');
This is problematic since ml_.capacity() != capacity() inside fbstring_core
for shared strings, which causes us not to un-share prior to push_back.
Test Plan: Existing tests, add unittest case.
Reviewed By: tudorb@fb.com
FB internal diff:
D580267
} else {
sz = ml_.size_;
newSz = ml_.size_ + delta;
- if (newSz > ml_.capacity()) {
+ if (newSz > capacity()) {
reserve(newSz);
}
}
reserve(maxSmallSize * 2);
} else {
sz = ml_.size_;
- cp = ml_.capacity();
+ cp = capacity(); // != ml_.capacity() for isShared()
if (sz == cp) reserve(cp * 3 / 2);
}
assert(capacity() >= sz + 1);
cp.push_back('?');
}
}
+ { // D580267
+ {
+ fbstring str(1337, 'f');
+ fbstring cp = str;
+ cp.push_back('f');
+ }
+ {
+ fbstring str(1337, 'f');
+ fbstring cp = str;
+ cp += "bb";
+ }
+ }
}
int main(int argc, char** argv) {