Commit 9ef4e8f1 authored by David Benjamin's avatar David Benjamin Committed by Commit Bot

Fix some issues caught by _LIBCPP_DEBUG=0

&vector[i] is invalid unless 0 <= i < vector.size(). This means:

- &vector[0] is invalid if the vector is empty.

- &vector[vector.size()] is not a valid way to point past the end of the
  vector.

Fix these to use vector.data() + vector.size() which is the defined to
get begin and end pointers for a vector.

Bug: chromium:1027059
Change-Id: Ife1f0e64807b32ebdca66dba8ffc206d90a0de75
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1929071
Auto-Submit: David Benjamin <davidben@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65091}
parent 25a4f4d9
......@@ -2505,8 +2505,8 @@ void Heap::ExternalStringTable::UpdateYoungReferences(
Heap::ExternalStringTableUpdaterCallback updater_func) {
if (young_strings_.empty()) return;
FullObjectSlot start(&young_strings_[0]);
FullObjectSlot end(&young_strings_[young_strings_.size()]);
FullObjectSlot start(young_strings_.data());
FullObjectSlot end(young_strings_.data() + young_strings_.size());
FullObjectSlot last = start;
for (FullObjectSlot p = start; p < end; ++p) {
......
......@@ -31,7 +31,7 @@ void DecodeUtf16(const std::vector<uint8_t>& bytes,
Utf8Decoder decoder(utf8_data);
std::vector<uint16_t> utf16(decoder.utf16_length());
decoder.Decode(&utf16[0], utf8_data);
decoder.Decode(utf16.data(), utf8_data);
// Decode back into code points
for (size_t i = 0; i < utf16.size(); i++) {
......@@ -48,8 +48,8 @@ void DecodeIncrementally(const std::vector<byte>& bytes,
std::vector<unibrow::uchar>* output) {
unibrow::Utf8::Utf8IncrementalBuffer buffer = 0;
unibrow::Utf8::State state = unibrow::Utf8::State::kAccept;
const byte* cursor = &bytes[0];
const byte* end = &bytes[bytes.size()];
const byte* cursor = bytes.data();
const byte* end = bytes.data() + bytes.size();
while (cursor < end) {
unibrow::uchar result =
unibrow::Utf8::ValueOfIncremental(&cursor, &state, &buffer);
......
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