summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-04-16 21:09:57 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-16 21:09:57 +0000
commit0d32b8fda53e02c1036d39f7290d4f59f2b58ca4 (patch)
tree820ea3b95c5ef566ea6c6c11fd6f113f0f895e70 /core/fpdfapi
parent574ee81e426a7390e5cdf28f2fe8ec03f6c2da98 (diff)
downloadpdfium-0d32b8fda53e02c1036d39f7290d4f59f2b58ca4.tar.xz
Revert "Return pdfium::span<wchar_t> from WideString::GetBuffer()."
This reverts commit 154e18f9a862975abecebe77b8f5fb418418d14c. Reason for revert: Generate CL to merge to beta branch Original change's description: > Return pdfium::span<wchar_t> from WideString::GetBuffer(). > > Adds bounds checking "for free", but beware of span outliving > a ReleaseBuffer() call. Scoping as such avoids the possibility > of using an invalid span (and it is flagged as a lifetime issue). > > Change-Id: Ica63f4b1429823d0254ec6951aeaeb08160cb93c > Reviewed-on: https://pdfium-review.googlesource.com/30310 > Reviewed-by: dsinclair <dsinclair@chromium.org> > Commit-Queue: Tom Sepez <tsepez@chromium.org> TBR=tsepez@chromium.org,dsinclair@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: Ie1ec9434215584a024538ca8edeb59dea555af48 Reviewed-on: https://pdfium-review.googlesource.com/30830 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/parser/fpdf_parser_decode.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp
index 90dca2edcb..d7114b66c5 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp
@@ -425,7 +425,6 @@ bool PDF_DataDecode(const uint8_t* src_buf,
}
WideString PDF_DecodeText(const uint8_t* src_data, uint32_t src_len) {
- int dest_pos = 0;
WideString result;
if (src_len >= 2 && ((src_data[0] == 0xfe && src_data[1] == 0xff) ||
(src_data[0] == 0xff && src_data[1] == 0xfe))) {
@@ -433,15 +432,17 @@ WideString PDF_DecodeText(const uint8_t* src_data, uint32_t src_len) {
if (!max_chars)
return result;
- pdfium::span<wchar_t> dest_buf = result.GetBuffer(max_chars);
bool bBE = src_data[0] == 0xfe || (src_data[0] == 0xff && !src_data[2]);
+ wchar_t* dest_buf = result.GetBuffer(max_chars);
const uint8_t* uni_str = src_data + 2;
+ int dest_pos = 0;
for (uint32_t i = 0; i < max_chars * 2; i += 2) {
uint16_t unicode = GetUnicodeFromBytes(uni_str + i, bBE);
if (unicode != 0x1b) {
dest_buf[dest_pos++] = unicode;
continue;
}
+
i += 2;
while (i < max_chars * 2) {
uint16_t unicode2 = GetUnicodeFromBytes(uni_str + i, bBE);
@@ -450,13 +451,13 @@ WideString PDF_DecodeText(const uint8_t* src_data, uint32_t src_len) {
break;
}
}
+ result.ReleaseBuffer(dest_pos);
} else {
- pdfium::span<wchar_t> dest_buf = result.GetBuffer(src_len);
+ wchar_t* dest_buf = result.GetBuffer(src_len);
for (uint32_t i = 0; i < src_len; ++i)
dest_buf[i] = PDFDocEncoding[src_data[i]];
- dest_pos = src_len;
+ result.ReleaseBuffer(src_len);
}
- result.ReleaseBuffer(dest_pos);
return result;
}