diff options
author | Bo Xu <bo_xu@foxitsoftware.com> | 2015-01-21 12:17:23 -0800 |
---|---|---|
committer | Bo Xu <bo_xu@foxitsoftware.com> | 2015-01-21 12:59:54 -0800 |
commit | a6f95eb2eb735e593f201a3ff9daad77c765cce0 (patch) | |
tree | 6d6e7bf325e782db19e00cc5c2b290206cec0e75 /fpdfsdk/src/fpdfview.cpp | |
parent | 96d1334cb605aab143d3135da4d4550920735e91 (diff) | |
download | pdfium-a6f95eb2eb735e593f201a3ff9daad77c765cce0.tar.xz |
Merge to XFA: 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.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp index 291b9f6d94..f084ce0da7 100644 --- a/fpdfsdk/src/fpdfview.cpp +++ b/fpdfsdk/src/fpdfview.cpp @@ -1055,11 +1055,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; } |