From 9352f4706a7aaf3d25ff4158ba4f83fbc9e86425 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 27 Dec 2018 13:45:55 +0000 Subject: [PATCH] Fix assertion failure in NativeProcessProtocolTest The assertion fired (with a debug visual studio STL) because we tried to dereference the end of a vector (although it was only to take its address again and form an end iterator). Rewrite this logic to avoid the questionable code. llvm-svn: 350091 --- lldb/unittests/Host/NativeProcessProtocolTest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lldb/unittests/Host/NativeProcessProtocolTest.cpp b/lldb/unittests/Host/NativeProcessProtocolTest.cpp index 39d636207a54..298c2909b616 100644 --- a/lldb/unittests/Host/NativeProcessProtocolTest.cpp +++ b/lldb/unittests/Host/NativeProcessProtocolTest.cpp @@ -131,7 +131,8 @@ llvm::Expected> FakeMemory::Read(addr_t Addr, return llvm::createStringError(llvm::inconvertibleErrorCode(), "Address out of range."); Size = std::min(Size, Data.size() - (size_t)Addr); - return std::vector(&Data[Addr], &Data[Addr + Size]); + auto Begin = std::next(Data.begin(), Addr); + return std::vector(Begin, std::next(Begin, Size)); } llvm::Expected FakeMemory::Write(addr_t Addr,