summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fxcrt/cfx_bytestring.cpp9
-rw-r--r--core/fxcrt/cfx_bytestring.h2
2 files changed, 7 insertions, 4 deletions
diff --git a/core/fxcrt/cfx_bytestring.cpp b/core/fxcrt/cfx_bytestring.cpp
index f6634fc51d..c29d24affd 100644
--- a/core/fxcrt/cfx_bytestring.cpp
+++ b/core/fxcrt/cfx_bytestring.cpp
@@ -10,6 +10,7 @@
#include <algorithm>
#include <cctype>
+#include <string>
#include "core/fxcrt/cfx_string_pool_template.h"
#include "core/fxcrt/fx_codepage.h"
@@ -195,9 +196,11 @@ CFX_ByteString::CFX_ByteString(
}
}
-CFX_ByteString::CFX_ByteString(std::ostringstream& outStream)
- : CFX_ByteString(outStream.str().c_str(),
- static_cast<int>(outStream.tellp())) {}
+CFX_ByteString::CFX_ByteString(const std::ostringstream& outStream) {
+ std::string str = outStream.str();
+ if (str.length() > 0)
+ m_pData.Reset(StringData::Create(str.c_str(), str.length()));
+}
CFX_ByteString::~CFX_ByteString() {}
diff --git a/core/fxcrt/cfx_bytestring.h b/core/fxcrt/cfx_bytestring.h
index 3f96c2f2f6..cf688b4c88 100644
--- a/core/fxcrt/cfx_bytestring.h
+++ b/core/fxcrt/cfx_bytestring.h
@@ -46,7 +46,7 @@ class CFX_ByteString {
explicit CFX_ByteString(const CFX_ByteStringC& bstrc);
CFX_ByteString(const CFX_ByteStringC& bstrc1, const CFX_ByteStringC& bstrc2);
CFX_ByteString(const std::initializer_list<CFX_ByteStringC>& list);
- explicit CFX_ByteString(std::ostringstream& outStream);
+ explicit CFX_ByteString(const std::ostringstream& outStream);
~CFX_ByteString();