diff --git a/lldb/source/Host/common/LZMA.cpp b/lldb/source/Host/common/LZMA.cpp
--- a/lldb/source/Host/common/LZMA.cpp
+++ b/lldb/source/Host/common/LZMA.cpp
@@ -76,7 +76,7 @@
 
   // Decode xz footer.
   lzma_ret xzerr = lzma_stream_footer_decode(
-      &opts, InputBuffer.data() + InputBuffer.size() - LZMA_STREAM_HEADER_SIZE);
+      &opts, InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE).data());
   if (xzerr != LZMA_OK) {
     return llvm::createStringError(llvm::inconvertibleErrorCode(),
                                    "lzma_stream_footer_decode()=%s",
@@ -94,11 +94,11 @@
   lzma_index *xzindex;
   uint64_t memlimit(UINT64_MAX);
   size_t inpos = 0;
-  xzerr =
-      lzma_index_buffer_decode(&xzindex, &memlimit, nullptr,
-                               InputBuffer.data() + InputBuffer.size() -
-                                   LZMA_STREAM_HEADER_SIZE - opts.backward_size,
-                               &inpos, InputBuffer.size());
+  xzerr = lzma_index_buffer_decode(
+      &xzindex, &memlimit, nullptr,
+      InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE + opts.backward_size)
+          .data(),
+      &inpos, InputBuffer.size());
   if (xzerr != LZMA_OK) {
     return llvm::createStringError(llvm::inconvertibleErrorCode(),
                                    "lzma_index_buffer_decode()=%s",