Commit bc02b7a4 authored by Lucian Grijincu's avatar Lucian Grijincu Committed by Facebook Github Bot 8

folly: fbstring: ubsan: memcpy/memmove are marked as nonnull - avoid calling...

folly: fbstring: ubsan: memcpy/memmove are marked as nonnull - avoid calling them when size == 0 and (likely) source is nullptr

Summary: Also see {D3295811}

Differential Revision: D3302564

fbshipit-source-id: 3f2dbf5a6cfa8199682cb4af90aac372d501919a
parent 3ce293fa
......@@ -400,7 +400,9 @@ public:
} else
#endif
{
fbstring_detail::pod_copy(data, data + size, small_);
if (size != 0) {
fbstring_detail::pod_copy(data, data + size, small_);
}
}
setSmallSize(size);
} else {
......@@ -1375,7 +1377,9 @@ public:
Invariant checker(*this);
// s can alias this, we need to use pod_move.
if (size() >= n) {
if (n == 0) {
resize(0);
} else if (size() >= n) {
fbstring_detail::pod_move(s, s + n, store_.mutable_data());
resize(n);
assert(size() == n);
......@@ -1736,10 +1740,9 @@ public:
enforce(pos <= size(), std::__throw_out_of_range, "");
procrustes(n, size() - pos);
fbstring_detail::pod_copy(
data() + pos,
data() + pos + n,
s);
if (n != 0) {
fbstring_detail::pod_copy(data() + pos, data() + pos + n, s);
}
return n;
}
......
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