Converting CFX_ByteTextBuf to ostringstream in fdpf_parser_decode.cpp.
Bug: pdfium:731
Change-Id: I20c3d87dba91d1489794abb77afcd2d7e9db88fe
Reviewed-on: https://pdfium-review.googlesource.com/6393
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp
index 3d7b9ff..a2ba203 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp
@@ -9,6 +9,7 @@
#include <limits.h>
#include <algorithm>
+#include <sstream>
#include <utility>
#include <vector>
@@ -512,20 +513,20 @@
}
CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, bool bHex) {
- CFX_ByteTextBuf result;
+ std::ostringstream result;
int srclen = src.GetLength();
if (bHex) {
- result.AppendChar('<');
+ result << '<';
for (int i = 0; i < srclen; i++) {
char buf[2];
FXSYS_IntToTwoHexChars(src[i], buf);
- result.AppendChar(buf[0]);
- result.AppendChar(buf[1]);
+ result << buf[0];
+ result << buf[1];
}
- result.AppendChar('>');
- return result.MakeString();
+ result << '>';
+ return CFX_ByteString(result);
}
- result.AppendChar('(');
+ result << '(';
for (int i = 0; i < srclen; i++) {
uint8_t ch = src[i];
if (ch == 0x0a) {
@@ -537,11 +538,11 @@
continue;
}
if (ch == ')' || ch == '\\' || ch == '(')
- result.AppendChar('\\');
- result.AppendChar(ch);
+ result << '\\';
+ result << static_cast<char>(ch);
}
- result.AppendChar(')');
- return result.MakeString();
+ result << ')';
+ return CFX_ByteString(result);
}
bool FlateEncode(const uint8_t* src_buf,