summaryrefslogtreecommitdiff
path: root/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2018-07-17 17:25:47 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-17 17:25:47 +0000
commita97a660d47cd500a00f69ad429de0ca1551c7198 (patch)
tree06c048d481398bed2d240055778f02bdce6eb758 /fxbarcode/oned/BC_OnedCodaBarWriter.cpp
parentff402c2c4ce8ae8690959262ca731d5cc6bd7015 (diff)
downloadpdfium-a97a660d47cd500a00f69ad429de0ca1551c7198.tar.xz
Reserve space for result in ::FilterContents
This changes the implementation for the specific bug listed and proactively fixes it in the other overrides. The general bug here is that if you concat a WideString in a tight loop without first reserving space, each call will cause an allocation size change and memcpy. This is very expensive and causes ClusterFuzz cases to timeout. BUG=chromium:863295 Change-Id: I6c1d900a31b98cd9ddcf91d1ec0f3973c9cdfa26 Reviewed-on: https://pdfium-review.googlesource.com/38110 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'fxbarcode/oned/BC_OnedCodaBarWriter.cpp')
-rw-r--r--fxbarcode/oned/BC_OnedCodaBarWriter.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/fxbarcode/oned/BC_OnedCodaBarWriter.cpp b/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
index 42990f7f3a..c51b1c2eb9 100644
--- a/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
+++ b/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
@@ -109,6 +109,7 @@ bool CBC_OnedCodaBarWriter::CheckContentValidity(
WideString CBC_OnedCodaBarWriter::FilterContents(
const WideStringView& contents) {
WideString filtercontents;
+ filtercontents.Reserve(contents.GetLength());
wchar_t ch;
for (size_t index = 0; index < contents.GetLength(); index++) {
ch = contents[index];