summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-08-10 22:38:53 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-10 22:38:53 +0000
commit8ba9749e2f39287137a96ec5ceff2ac694566f48 (patch)
tree7575917a1b829a95b91c47be2520d7a1ea77e030 /core/fpdfapi/parser
parentc51e0a0f9b2fbaa9f2eb911ab71f0d76d0215a94 (diff)
downloadpdfium-8ba9749e2f39287137a96ec5ceff2ac694566f48.tar.xz
Remove unused form of PDF_EncodeText().
Perform indexing via WideString::operator[] which will at least assert bounds, if not enforce them. Change-Id: I7b03cfd718c4acd642af910c2ca06f86d178e5fd Reviewed-on: https://pdfium-review.googlesource.com/39873 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r--core/fpdfapi/parser/fpdf_parser_decode.cpp21
-rw-r--r--core/fpdfapi/parser/fpdf_parser_decode.h1
2 files changed, 7 insertions, 15 deletions
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp
index 9ccca121ad..928d650103 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp
@@ -467,21 +467,18 @@ WideString PDF_DecodeText(const ByteString& bstr) {
bstr.GetLength());
}
-ByteString PDF_EncodeText(const wchar_t* pString, int len) {
- if (len == -1)
- len = wcslen(pString);
-
- int i;
+ByteString PDF_EncodeText(const WideString& str) {
+ size_t i = 0;
+ size_t len = str.GetLength();
ByteString result;
{
pdfium::span<char> dest_buf = result.GetBuffer(len);
for (i = 0; i < len; ++i) {
int code;
for (code = 0; code < 256; ++code) {
- if (PDFDocEncoding[code] == pString[i])
+ if (PDFDocEncoding[code] == str[i])
break;
}
-
if (code == 256)
break;
@@ -504,19 +501,15 @@ ByteString PDF_EncodeText(const wchar_t* pString, int len) {
pdfium::as_writable_bytes(result.GetBuffer(encLen));
dest_buf[dest_index++] = 0xfe;
dest_buf[dest_index++] = 0xff;
- for (int j = 0; j < len; ++j) {
- dest_buf[dest_index++] = pString[j] >> 8;
- dest_buf[dest_index++] = static_cast<uint8_t>(pString[j]);
+ for (size_t j = 0; j < len; ++j) {
+ dest_buf[dest_index++] = str[j] >> 8;
+ dest_buf[dest_index++] = static_cast<uint8_t>(str[j]);
}
}
result.ReleaseBuffer(encLen);
return result;
}
-ByteString PDF_EncodeText(const WideString& str) {
- return PDF_EncodeText(str.c_str(), str.GetLength());
-}
-
ByteString PDF_EncodeString(const ByteString& src, bool bHex) {
std::ostringstream result;
int srclen = src.GetLength();
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.h b/core/fpdfapi/parser/fpdf_parser_decode.h
index 328fd474c6..652299992a 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.h
+++ b/core/fpdfapi/parser/fpdf_parser_decode.h
@@ -21,7 +21,6 @@ extern const uint16_t PDFDocEncoding[256];
ByteString PDF_EncodeString(const ByteString& src, bool bHex);
WideString PDF_DecodeText(const uint8_t* pData, uint32_t size);
WideString PDF_DecodeText(const ByteString& bstr);
-ByteString PDF_EncodeText(const wchar_t* pString, int len);
ByteString PDF_EncodeText(const WideString& str);
bool FlateEncode(const uint8_t* src_buf,