[zone] Avoid undefined behavior in edge case
If buffer_ is empty and start_ is zero, even though the MemCopy would be a no-op, &buffer_[start_] is undefined. buffer_.data() + start_ would work, but due to a C/C++ language bug, that is technically undefined too[*] if an empty buffer_.data() returns nullptr, so add a length() == 0 check, matching methods above. This was caught by building with _LIBCPP_DEBUG=0. [*] https://www.imperialviolet.org/2016/06/26/nonnull.html Bug: chromium:893810 Change-Id: I9f0834ffae6769e0e191e786842e6ecc6c95a58a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1483616Reviewed-by: Toon Verwaest <verwaest@chromium.org> Commit-Queue: David Benjamin <davidben@chromium.org> Cr-Commit-Position: refs/heads/master@{#60016}
Showing
Please
register
or
sign in
to comment