From a97a660d47cd500a00f69ad429de0ca1551c7198 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Tue, 17 Jul 2018 17:25:47 +0000 Subject: 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 Reviewed-by: Henrique Nakashima Commit-Queue: Ryan Harrison --- fxbarcode/oned/BC_OnedCode39Writer.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'fxbarcode/oned/BC_OnedCode39Writer.cpp') diff --git a/fxbarcode/oned/BC_OnedCode39Writer.cpp b/fxbarcode/oned/BC_OnedCode39Writer.cpp index f04dc195ea..9152155e29 100644 --- a/fxbarcode/oned/BC_OnedCode39Writer.cpp +++ b/fxbarcode/oned/BC_OnedCode39Writer.cpp @@ -73,6 +73,7 @@ bool CBC_OnedCode39Writer::CheckContentValidity( WideString CBC_OnedCode39Writer::FilterContents( const WideStringView& contents) { WideString filtercontents; + filtercontents.Reserve(contents.GetLength()); for (size_t i = 0; i < contents.GetLength(); i++) { wchar_t ch = contents[i]; if (ch == L'*' && (i == 0 || i == contents.GetLength() - 1)) { -- cgit v1.2.3