From 4f5ccaaecd7e524e98b79af6823a9ab6a8753d7f Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Sat, 13 Oct 2018 06:39:00 +0000 Subject: Fix span / unique_ptr destruction order in PDF_DataDecode(). BUG=chromium:895026 Change-Id: Ie7d8bfd6e42308c3531ce6637ad29ec2231a2095 Reviewed-on: https://pdfium-review.googlesource.com/c/43984 Reviewed-by: Tom Sepez Commit-Queue: Lei Zhang --- core/fpdfapi/parser/fpdf_parser_decode.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp index 99b6154e8d..2b27b89970 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp @@ -389,8 +389,10 @@ bool PDF_DataDecode(pdfium::span src_span, {pDecoder->GetString(), pParams ? pParams->GetDict() : nullptr}); } - pdfium::span last_span = src_span; std::unique_ptr result; + // May be changed to point to |result| in the for-loop below. So put it below + // |result| and let it get destroyed first. + pdfium::span last_span = src_span; size_t nSize = DecoderArray.size(); for (size_t i = 0; i < nSize; ++i) { int estimated_size = i == nSize - 1 ? last_estimated_size : 0; -- cgit v1.2.3