[VM/Runtime] - Fix ubsan warning.

TEST=ci

Change-Id: I9881db82771c51a1df8fe930fe2216ddf87f5746
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285345
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
asiva 2023-02-24 23:01:28 +00:00 committed by Commit Queue
parent c90821350e
commit a346af7b7a

View file

@ -509,7 +509,10 @@ CodeSourceMapPtr CodeSourceMapBuilder::Finalize() {
intptr_t length = stream_.bytes_written();
const auto& map = CodeSourceMap::Handle(zone_, CodeSourceMap::New(length));
NoSafepointScope no_safepoint;
memmove(map.Data(), stream_.buffer(), length);
if (length > 0) {
ASSERT(stream_.buffer() != nullptr);
memmove(map.Data(), stream_.buffer(), length);
}
return map.ptr();
}