Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1214)

Unified Diff: Source/modules/encoding/TextEncoder.cpp

Issue 313393005: Encoding API: Handle null input string (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/encoding/api/basics.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/encoding/TextEncoder.cpp
diff --git a/Source/modules/encoding/TextEncoder.cpp b/Source/modules/encoding/TextEncoder.cpp
index b1d2be1afa8e37e9920bf1c661c44c5ea636e398..a669e0272d11dec6c3a1ad3e3f6a4def86744287 100644
--- a/Source/modules/encoding/TextEncoder.cpp
+++ b/Source/modules/encoding/TextEncoder.cpp
@@ -84,10 +84,12 @@ PassRefPtr<Uint8Array> TextEncoder::encode(const String& input, const Dictionary
// handle split surrogates here.
CString result;
- if (input.is8Bit())
- result = m_codec->encode(input.characters8(), input.length(), WTF::QuestionMarksForUnencodables);
- else
- result = m_codec->encode(input.characters16(), input.length(), WTF::QuestionMarksForUnencodables);
+ if (!input.isNull()) {
+ if (input.is8Bit())
+ result = m_codec->encode(input.characters8(), input.length(), WTF::QuestionMarksForUnencodables);
+ else
+ result = m_codec->encode(input.characters16(), input.length(), WTF::QuestionMarksForUnencodables);
+ }
const char* buffer = result.data();
const unsigned char* unsignedBuffer = reinterpret_cast<const unsigned char*>(buffer);
« no previous file with comments | « LayoutTests/fast/encoding/api/basics.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698