summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfview.cpp
diff options
context:
space:
mode:
authorBo Xu <bo_xu@foxitsoftware.com>2015-01-21 12:17:23 -0800
committerBo Xu <bo_xu@foxitsoftware.com>2015-01-21 12:17:23 -0800
commit0185408126529d5df7e095c5789affd4ae971375 (patch)
tree093caeab0a75ed18a26ffc3ff950b624c3e59460 /fpdfsdk/src/fpdfview.cpp
parentaa7b4ede03764a5701a477b601720a32c88d8e42 (diff)
downloadpdfium-0185408126529d5df7e095c5789affd4ae971375.tar.xz
Simplify UTF16LE_Encode and add unittest.
Previously, UTF16LE_Encode take an optional flag to indicate if the returned byte string has trailing zeros. In fact, no where needs the flag to be false. So just get rid of it so callers won't misuse. The bug is found by https://codereview.chromium.org/837723009 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/860973002
Diffstat (limited to 'fpdfsdk/src/fpdfview.cpp')
-rw-r--r--fpdfsdk/src/fpdfview.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index 43feaf4d5a..87ef3ee5b2 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -855,11 +855,9 @@ DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index,
CFX_ByteString utf16Name = wsName.UTF16LE_Encode();
unsigned int len = utf16Name.GetLength();
if (!buffer) {
- buflen = len + 2;
- } else if (buflen >= len + 2) {
+ buflen = len;
+ } else if (buflen >= len) {
memcpy(buffer, utf16Name.c_str(), len);
- ((FX_BYTE*)buffer)[len] = 0;
- ((FX_BYTE*)buffer)[len + 1] = 0;
} else {
len = -1;
}