summaryrefslogtreecommitdiff
path: root/core/fxcodec/codec/ccodec_progressivedecoder.cpp
AgeCommit message (Collapse)Author
2018-10-15Stop shadowing codec memory size with CCodec_ProgressiveDecoder::m_SrcSizeTom Sepez
This is a remnant from the old implementation which can get out of sync with the actual value, esp. in the fuzzers where buffers are shorter-lived. Bug: 895009 Change-Id: Ibf16dad58dd750c961e3b446f12cb2197004dbb4 Reviewed-on: https://pdfium-review.googlesource.com/c/44010 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-12Forward declare more in codec code.Lei Zhang
Change-Id: I8060ada299f845a9198a6e83d31d128bd4bf09bc Reviewed-on: https://pdfium-review.googlesource.com/c/43870 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-10Fix dangling reference in CFX_CodecMemory.Tom Sepez
Do this by making CFX_CodecMemory actually own the memory that it is ref-counting. Remove some test cases that are now prohibited, and relax one lifetime restriction in the test because we are now doing one additional copy (in the test, but not in real life). Bug:879512 Change-Id: If030dfcf97fe40155c46a42288fc73192437ce9c Reviewed-on: https://pdfium-review.googlesource.com/c/43670 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-10-09Pass CFX_CodecMemory in place of spans to codecs.Tom Sepez
Next step towards making CFX_CodecMemory own the memory it is ref-counting. Change-Id: I5922d80d13032c3ea028447c47d34a10234109a3 Reviewed-on: https://pdfium-review.googlesource.com/c/43630 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-09Kill off some memset()s following FX_Alloc()Tom Sepez
Change-Id: I92aa74c86aef890fcb991f039b9707d680fdb83c Reviewed-on: https://pdfium-review.googlesource.com/c/43652 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-03Make CCodec_ProgressiveDecoder::ReadMoreData() slightly sanerchromium/3570Tom Sepez
- Fix buffer leak if TryRealloc fails. - Make m_SrcSize always represent the usable bytes in the buffer, even when read the last partial block from the file. - Remove redundant comparisons and use std::min(). - Better naming. Change-Id: Ie7dd79bac21b2f2422f299563a2dd28ed358e3e2 Reviewed-on: https://pdfium-review.googlesource.com/42130 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-10-02Consolidate ReadMoreData() calls.Tom Sepez
Extract some dividends from having landed the previous CL. Change-Id: I9ade77c801b51762cab801716b9fd2bc4c634036 Reviewed-on: https://pdfium-review.googlesource.com/c/41990 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-09-25Add FxAlignToBoundary<>() template helper function.Tom Sepez
Because I nearly botched this trivial calculation in the previous CL. Change-Id: I7438f9d3476d93b7899c2d7d761234769f53f9e3 Reviewed-on: https://pdfium-review.googlesource.com/43010 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-09-25Introduce CodecModuleIface for progressive decoder modules.Tom Sepez
Another step before trying to fix the memory issue. Forces common APIs on the bunch of decoders, though some methods are unused. Requires adding some arguments/return values to get to a common API which are not used in all cases (yet?). Required converting some args to spans. Required proxying a GetJumpMark() call through the public module API to the private context. Bug: pdfium:1082 Change-Id: I0c0b7415141ff2a6f4f44777ca3d05521f08130d Reviewed-on: https://pdfium-review.googlesource.com/41950 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-09-04Consolidate some common code in ccoded_progressivedecoder.Tom Sepez
Small consolidation before trying to fix a memory issue. Unfortunately, this involves converting a switch -> ifs, since we no longer dispatch exactly the same. Change-Id: I7ef61db98cdfbbc983adf21e7b3fe4ef1d2ce869 Reviewed-on: https://pdfium-review.googlesource.com/41830 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-31Remove avail_buf out argument from GetAvailInput() methods.chromium/3542chromium/3541chromium/3540chromium/3539Tom Sepez
It's always passed as nullptr. It's a good thing, too, since it looks like some of the implementations are returning a wrong pointer. Add some missing |const|s. Change-Id: I768048fdfe4cdd1dc838fee26fec18e024e39920 Reviewed-on: https://pdfium-review.googlesource.com/41810 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-30Fix lifetime issue in CCodec_ProgressiveDecoder.Tom Sepez
The associated bug is caused by failure to clean up context before returing at line 740 or so. But cleanups are fragile, so instead do not move context out of a local until success. This in turn means passing the local to one helper rather that using the stored value and confirming this is the only helper method invoked during the time in which the context is not yet stored. Bug: 879025 Change-Id: I1acb438edc28f7f4dd8acccc2461fe3a5ea7f5c8 Reviewed-on: https://pdfium-review.googlesource.com/41670 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-28Let CCodec_ProgressiveDecoder::m_pSrcBuf outlive contextsTom Sepez
This requires making some members unique_ptr<> to preserve the destruction order. Bug: 877766 Change-Id: I69e0173fdde7e9cd0d24017d6c829b9b9cf600c0 Reviewed-on: https://pdfium-review.googlesource.com/41490 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-27Rework CCODEC_ProgressiveDecoder.Tom Sepez
Rename .cpp file to match class and .h file (!!!) Put initialziations into header. Change-Id: I2cbc7608287f8df887ce186d122dcd3db2aef19b Reviewed-on: https://pdfium-review.googlesource.com/41511 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>