From fc9b11358a47e1dd9b257263c9457d7e53b9dd10 Mon Sep 17 00:00:00 2001 From: npm Date: Wed, 31 Aug 2016 10:51:20 -0700 Subject: Move maxNumDataBytes and maxNumEcBytes calculation to fix crash The blocks.Add will std::move the unique_ptrs, so the std::max calculations need to go before. Without this change, pdfium_test will crash when trying to render test/barcode_test.pdf with XFA enabled. Tested that after this change, barcode_test.pdf is rendered without crashing. Review-Url: https://codereview.chromium.org/2298833002 --- xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp index 7f332b671e..209a9656a6 100644 --- a/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp +++ b/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp @@ -885,10 +885,10 @@ void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits, std::unique_ptr ecBytes( GenerateECBytes(dataBytes.get(), numEcBytesInBlosk, e)); BC_EXCEPTION_CHECK_ReturnVoid(e); - blocks.Add( - new CBC_QRCoderBlockPair(std::move(dataBytes), std::move(ecBytes))); maxNumDataBytes = std::max(maxNumDataBytes, dataBytes->Size()); maxNumEcBytes = std::max(maxNumEcBytes, ecBytes->Size()); + blocks.Add( + new CBC_QRCoderBlockPair(std::move(dataBytes), std::move(ecBytes))); dataBytesOffset += numDataBytesInBlock; } if (numDataBytes != dataBytesOffset) { -- cgit v1.2.3