summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdftext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fpdftext.cpp')
-rw-r--r--fpdfsdk/fpdftext.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/fpdfsdk/fpdftext.cpp b/fpdfsdk/fpdftext.cpp
index 6a030b8ebd..ee4354735e 100644
--- a/fpdfsdk/fpdftext.cpp
+++ b/fpdfsdk/fpdftext.cpp
@@ -175,6 +175,10 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetText(FPDF_TEXTPAGE text_page,
if (str.GetLength() <= 0)
return 0;
+ ASSERT(str.GetLength() <= static_cast<FX_STRSIZE>(count));
+ if (str.GetLength() > static_cast<FX_STRSIZE>(count))
+ str = str.Left(static_cast<FX_STRSIZE>(count));
+
// UFT16LE_Encode doesn't handle surrogate pairs properly, so it is expected
// the number of items to stay the same.
CFX_ByteString cbUTF16str = str.UTF16LE_Encode();