summaryrefslogtreecommitdiff
path: root/core/fxcrt/bytestring.h
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-04-12 19:45:45 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-12 19:45:45 +0000
commit80a6cbe0a427e155de8555bc867af745d10f9777 (patch)
treef5a01546d4081a4c3618350f4b54d13690d30299 /core/fxcrt/bytestring.h
parent154e18f9a862975abecebe77b8f5fb418418d14c (diff)
downloadpdfium-80a6cbe0a427e155de8555bc867af745d10f9777.tar.xz
Return pdfium::span<char> from ByteString::GetBuffer().
Get bounds checking "for free". Change-Id: I7b14cacbc7130ced7b5cb1869b82c96ccff8e642 Reviewed-on: https://pdfium-review.googlesource.com/30451 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/bytestring.h')
-rw-r--r--core/fxcrt/bytestring.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h
index 70f10dcaba..c68d2f6991 100644
--- a/core/fxcrt/bytestring.h
+++ b/core/fxcrt/bytestring.h
@@ -17,6 +17,7 @@
#include "core/fxcrt/string_data_template.h"
#include "core/fxcrt/string_view_template.h"
#include "third_party/base/optional.h"
+#include "third_party/base/span.h"
namespace fxcrt {
@@ -145,7 +146,10 @@ class ByteString {
size_t Delete(size_t index, size_t count = 1);
void Reserve(size_t len);
- char* GetBuffer(size_t len);
+
+ // Note: any modification of the string (including ReleaseBuffer()) may
+ // invalidate the span, which must not outlive its buffer.
+ pdfium::span<char> GetBuffer(size_t len);
void ReleaseBuffer(size_t len);
ByteString Mid(size_t first, size_t count) const;