summaryrefslogtreecommitdiff
path: root/core
AgeCommit message (Collapse)Author
2018-05-14Cleanup CPDF_Form parsing codechromium/3431Dan Sinclair
This CL folds the StartParse() method of CPDF_Form into the ParserContent method. The no arguments ParseContent is removed and ParseContentWithParams renamed to ParseContent. The callsites are updated to pass the nullptr's. Bug: chromium:813349 Change-Id: I304b77aef1de1b9aa20e4a3044db5023f5701584 Reviewed-on: https://pdfium-review.googlesource.com/32511 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-05-14Use internal wcstof instead of system wcstod in formcalc lexerDan Sinclair
This CL switches the usage of wcstod to use the FXSYS_wcstof to determine if a given string is a valid floating point number. Using the internal method makes linux slightly slower (10's of ms) makes mac a lot faster 900ms to 60ms for the test case in the bug. The FXSYS_wcstof method has been extended to handle the parsing of float exponents. Unittests were added for FXSYS_wcstof. Bug: chromium:813646 Change-Id: Ie68287a336e3b95a0c0b845d5bf39db6fc82b39c Reviewed-on: https://pdfium-review.googlesource.com/32510 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-05-14Merge some values of JBig2_ResultNicolas Pena
This CL merges some of the values of JBig2_Result. The only checks are against Success and EndOfFile || EndOfPage, so we only need three values: Success, EndReached, and Failure (for anything that does not match either of those two). Change-Id: I552c54f2d70aa8e8bf52702dab4dfc00d528ef76 Reviewed-on: https://pdfium-review.googlesource.com/32393 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-05-11Reland "Filter out "Type" and "DecodeParms" from trailer keys."Henrique Nakashima
This reverts commit 466bd4f4e0cb2bc2a7b3626948609268c52c4690. Reason for revert: On closer inspection, it seems the test is not flaky, and the root cause of the failure is an SEH exception, which is the true source of flakiness. Other tests are also affected. Original change's description: > Revert "Filter out "Type" and "DecodeParms" from trailer keys." > > This reverts commit 5f7c5be8b7072d46e8d8088a1ec14370ecfad44c. > > Reason for revert: New test is flaky, ID is not stable. > > Original change's description: > > Filter out "Type" and "DecodeParms" from trailer keys. > > > > Bug: pdfium:873 > > Change-Id: I12ae5b8776f5a73c4be81bed53ada05c94d46882 > > Reviewed-on: https://pdfium-review.googlesource.com/32190 > > Reviewed-by: dsinclair <dsinclair@chromium.org> > > Commit-Queue: dsinclair <dsinclair@chromium.org> > > TBR=dsinclair@chromium.org,hnakashima@chromium.org > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Bug: pdfium:873 > Change-Id: I642771e12c61181c7b81681dae7b2f5549c14b18 > Reviewed-on: https://pdfium-review.googlesource.com/32430 > Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> > Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> TBR=dsinclair@chromium.org,hnakashima@chromium.org Change-Id: I2552729610c9f8adf02c70a2a43e2383ceda19b5 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: pdfium:873 Reviewed-on: https://pdfium-review.googlesource.com/32397 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-05-11Revert "Filter out "Type" and "DecodeParms" from trailer keys."Henrique Nakashima
This reverts commit 5f7c5be8b7072d46e8d8088a1ec14370ecfad44c. Reason for revert: New test is flaky, ID is not stable. Original change's description: > Filter out "Type" and "DecodeParms" from trailer keys. > > Bug: pdfium:873 > Change-Id: I12ae5b8776f5a73c4be81bed53ada05c94d46882 > Reviewed-on: https://pdfium-review.googlesource.com/32190 > Reviewed-by: dsinclair <dsinclair@chromium.org> > Commit-Queue: dsinclair <dsinclair@chromium.org> TBR=dsinclair@chromium.org,hnakashima@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: pdfium:873 Change-Id: I642771e12c61181c7b81681dae7b2f5549c14b18 Reviewed-on: https://pdfium-review.googlesource.com/32430 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-05-11Use more smart pointer types in CPDF_DIBSource.Tom Sepez
Use one std::vector<>, too. As a result, make GetDecodeAndMaskArray() update that member directly rather than forcing callers to assign to it each time. Change-Id: I51a039b9e8cce7ff885edf395622eaf6a5c4816a Reviewed-on: https://pdfium-review.googlesource.com/32313 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-10Fixup ASSERT in Bidi handling; Add bidi fuzzer.Dan Sinclair
This CL converts several asserts in the FX_Bidi code to continue instead of asserting in the face of unexpected input. A BIDI fuzzer has been added as well. Bug: chromium:839695 Change-Id: If61f822bde7442c008d50be58f7cecffb6e5d658 Reviewed-on: https://pdfium-review.googlesource.com/32191 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-05-10Clean up post review commentsRyan Harrison
Cleaning up some nits that came in after my previous codec CL had gone into the CQ. BUG=pdfium:1080 Change-Id: I3845136d370f73c9c96ef732e95b8cf0c9c79d91 Reviewed-on: https://pdfium-review.googlesource.com/32351 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-05-10Add CPDF_Transparency.Lei Zhang
Encapsulates transparency status instead of having it be a raw int. Change-Id: I8b10dafa97da112795cf84c46cf416a0294551d5 Reviewed-on: https://pdfium-review.googlesource.com/32194 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-10Fix destruction order in CPDF_Dibsource.Tom Sepez
The order of the elements in the header is correct, but we were clearing it early in the destructor itself. Bug: 840695 Change-Id: I1585722fed8dc672ffd5e1dc9a1eea1c7c80f310 Reviewed-on: https://pdfium-review.googlesource.com/32311 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-05-10Remove a completeness check from CJBig2_GRRDProc::DecodeTemplate0OptNicolas Pena
https://pdfium-review.googlesource.com/c/pdfium/+/18333 introduced several checks to prevent timeouts in JBig2. One of these is breaking the PDF in the bug, so this CL removes that check. Bug: chromium:841200 Change-Id: Ia75c699b7fddc26f0353b0d64349898c4d1f744d Reviewed-on: https://pdfium-review.googlesource.com/32250 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-05-10Do not build BMP when codec is disabledRyan Harrison
Currently all of the BMP related code is being built when support for the codec is disabled, it just isn't being utilized. Depending on the settings being used, this unneeded code may or may not get stripped during linking. This CL explicitly turns off building the BMP codec code if support for BMP is turned off. BUG=pdfium:1080 Change-Id: I56d40639a5a3631f9c601a1eef3f98873feac94f Reviewed-on: https://pdfium-review.googlesource.com/32370 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-09Use enum class instead of int in CJBig2_Contextchromium/3426Nicolas Pena
This CL changes CJBig2_Context return methods as follows: * Internal methods return JBig2_Result instead of int. * Public methods return a bool (for success/failure) instead of int. In a followup, several of the enum class values may be merged together since they are not all needed. Change-Id: Ifdab83b8037262370cd7c4a80e94aa94d59aa589 Reviewed-on: https://pdfium-review.googlesource.com/32310 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-05-09Add proper const/non-const versions of CPDF_Array methods.Lei Zhang
Instead of having const methods that return non-const pointers. BUG=pdfium:234 Change-Id: I61495543f67229500dfcf2248e93468e9a9b23cf Reviewed-on: https://pdfium-review.googlesource.com/32183 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-05-09Add proper const/non-const versions of CPDF_Object methods.Lei Zhang
Instead of having const methods that return non-const pointers. BUG=pdfium:234 Change-Id: I598e9b4f267f702e2e71001cfe3aa3c9e9d8c12f Reviewed-on: https://pdfium-review.googlesource.com/32182 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-05-09Split the MaybeOwned CPDF_Dictionary in CPDF_FlateEncoder.Lei Zhang
The owned copy needs to be modified, so it should be non-const. Whereas the unowned copy can be const. Add a GetClonedDict() method for accessing the modifiable dictionary. Change-Id: Ia7f6bcc5f917864cd1bbc7b5000a86f6e433ae9a Reviewed-on: https://pdfium-review.googlesource.com/32181 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-09Do not build GIF when codec is disabledRyan Harrison
Currently all of the GIF related code is being built when support for the codec is disabled, it just isn't being utilized. Depending on the settings being used, this unneeded code may or may not get stripped during linking. This CL explicitly turns off building the GIF codec code if support for GIF is turned off. This also catches a few missed cases from previous CLs. BUG=pdfium:1080 Change-Id: Ie7fe2d894d2ae2f8f36ae05e0ff256f2ce6ef8d4 Reviewed-on: https://pdfium-review.googlesource.com/32330 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-05-09Do not build PNG when codec is disabledRyan Harrison
Currently all of the PNG related code is being built when support for the codec is disabled, it just isn't being utilized. Depending on the settings being used, this unneeded code may or may not get stripped during linking. This CL explicitly turns off building the PNG codec code if support for PNG is turned off. BUG=pdfium:1080 Change-Id: I9c5247145fcadbcb1bd2243aa83350304ba421ff Reviewed-on: https://pdfium-review.googlesource.com/32270 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-05-09Mark numerious pointers as const.Lei Zhang
They are mostly CPDF_Object* and derived classes, but others that should be are marked const as well. Change-Id: Ib3344d7d8db90940df8edc97c0dd6c59da080541 Reviewed-on: https://pdfium-review.googlesource.com/32180 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-05-09Add constants for PDF 1.7 spec, table 7.13.Lei Zhang
BUG=pdfium:1049 Change-Id: I3a589fe51f2e584dc130ba31faa144d4494a1b08 Reviewed-on: https://pdfium-review.googlesource.com/32179 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-09Break backcolor code out of CPDF_RenderStatus::LoadSMask().Lei Zhang
Fix some nits in the code in the process. Change-Id: I660b3bf547823a11bc291ed2dd1ec19a76b24b5b Reviewed-on: https://pdfium-review.googlesource.com/32178 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-09Make memory usage in CJBig2_HTRDProc::DecodeImage() O(1).Lei Zhang
Instead of allocating an N-pixel array to store some temporary values, just use a single integer. BUG=chromium:840728 Change-Id: I7a0ff83d814eff127033f25020a7c398db3c2062 Reviewed-on: https://pdfium-review.googlesource.com/32290 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-05-09Do not build TIFF when codec is disabledRyan Harrison
Currently all of the TIFF related code is being built when support for the codec is disabled, it just isn't being utilized. Depending on the settings being used, this unneeded code may or may not get stripped during linking. This CL explicitly turns off building the TIFF codec code if support for TIFF is turned off. It also fixes cases in the code base where tif was being used instead of tiff. BUG=pdfium:1080 Change-Id: If6aaa8af5160fdd5b261e63bab7d5984196efcc9 Reviewed-on: https://pdfium-review.googlesource.com/32193 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-05-09Filter out "Type" and "DecodeParms" from trailer keys.Henrique Nakashima
Bug: pdfium:873 Change-Id: I12ae5b8776f5a73c4be81bed53ada05c94d46882 Reviewed-on: https://pdfium-review.googlesource.com/32190 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-05-08Mark CPDF_Object pointers as const in CPDF_ViewerPreferences.Lei Zhang
Work up the short call stack and mark FPDF_PAGERANGE as an opaque const pointer. Also fix CPDF_ViewerPreferences::GenericName() to return an optional string. Change-Id: I2356d38888fcff8d4da37dd3efc17b284ff90485 Reviewed-on: https://pdfium-review.googlesource.com/32174 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-08Remove almost all usages of CFX_FixedBufGrow with std::vectorNicolas Pena
Tested by running safetynet_compare.py on this patch vs master. The results were 0 regressions and 0 improvements. The two remaining usages cannot be replaced because they would cause a regression. Bug: pdfium:177 Change-Id: I43eddf4ffaac2eb063f2004d6606bc3cd6e627ac Reviewed-on: https://pdfium-review.googlesource.com/32159 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-05-08Remove PDFTRANS_KNOCKOUT.Lei Zhang
No code actually checks to see if it is set. Change-Id: I37631713d568f116df1c0495ffd7d7d64ddce69a Reviewed-on: https://pdfium-review.googlesource.com/32186 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-08Add constants for PDF 1.7 spec, table 7.2 and 7.3.Lei Zhang
Add constants/transparency.h. The header lists constants from chapter 7 of the PDF spec. BUG=pdfium:1049 Change-Id: I66bd6fceb24807eec9c308e2e47cec3f2f836ffb Reviewed-on: https://pdfium-review.googlesource.com/32177 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-08Split CCodec_FlateScanlineDecoder in two.Lei Zhang
Move the predictor code into the CCodec_FlatePredictorScanlineDecoder sub-class. Change-Id: I5a56ba5e051cf55e8fdd039bd38089684ed257be Reviewed-on: https://pdfium-review.googlesource.com/31272 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-05-08Simplify more code in CPDF_TextObject.Lei Zhang
- Move code into a GenerateSpace() function. - Break apart some font size conversions. Change-Id: I4d5ea112fc004a31ac38b7c19ff77fcbfe764d38 Reviewed-on: https://pdfium-review.googlesource.com/32157 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-05-08[fm2js] Create fewer CFX_WideTextBuf classesDan Sinclair
This CL modifies the formcalc transpiler to create less CFX_WideTextBuf classes as we convert to JavaScript. This can take some pathalogical formcal from 20sec to convert to .5sec. Bug: chromium:834575 Change-Id: I428883297bbc3a6a325a4ab0ad51834f2f02ab82 Reviewed-on: https://pdfium-review.googlesource.com/32154 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-05-08Move CalculatePitch8() to core/fxcodec.Lei Zhang
Use it in more places there. Change-Id: I477670a5946ec9033ad5f2bef0fbcddb52682066 Reviewed-on: https://pdfium-review.googlesource.com/31271 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-05-08Rename CPDF_Document::GetPage() to GetPageDictionary().Tom Sepez
Avoids a conflict should we wish to have the document actually track pages, with a GetPage() that returns CPDF_Page. Do the same thing to CPDF_DataAvail along the way. Add some missing consts as well. Change-Id: I2cb2213cc4c0649662fceab80407ee4a3f4cf30e Reviewed-on: https://pdfium-review.googlesource.com/32158 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-08Make one more CPDF_PageObjectHolder member protected.Lei Zhang
Change-Id: Id9288d504f063759f69632ab59b0a21569ff76d8 Reviewed-on: https://pdfium-review.googlesource.com/32113 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-07Make more CPDF_PageObjectHolder members protected.Lei Zhang
Change-Id: Id31b9f6ac33971c47cdb378ff7f9ca7d33f899b9 Reviewed-on: https://pdfium-review.googlesource.com/32112 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-07Make CPDF_PageObjectHolder::m_iTransparency protected.Lei Zhang
Also initialize members in the header. Change-Id: Id814c4c5042c9d4989fa92b78f68c17f4949f09d Reviewed-on: https://pdfium-review.googlesource.com/32111 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-07Add some getters for CPDF_PageObjectHolder.Lei Zhang
Change-Id: I3fe99ecb17d37f893ce5d0d59219c82ee31fe7ea Reviewed-on: https://pdfium-review.googlesource.com/32110 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-07Move codepage tables from cpdf_document.cpp to fx_codepage.cppTom Sepez
Avoids scrolling past this noise when looking at document code. No functional changes. Change-Id: I4684a8cf4d8894c699cd1c980bc5fc41b2179ad1 Reviewed-on: https://pdfium-review.googlesource.com/32156 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-07Use unowned ptr for CPDF_Page::m_pView.Tom Sepez
Change-Id: I9d87cefc18a3a468e1bec797bc7711194f6444c7 Reviewed-on: https://pdfium-review.googlesource.com/32155 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-05-07Move some CPDF_TextPage methods into an anonymous namespace.Lei Zhang
Change-Id: I959d687d7d46fa61e1fe097b0b876ad02d2b123c Reviewed-on: https://pdfium-review.googlesource.com/32153 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-05-07Initialize CPDF_RenderStatus members in the header.Lei Zhang
Also move static private members into the .cpp file. Change-Id: Idbbdc7c78ac4199968888466caa20c58a5653dfd Reviewed-on: https://pdfium-review.googlesource.com/32151 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-05-07Initialize CPDF_TextPage members in the header.Lei Zhang
Change-Id: I667a3cd696d44692fa3d73bdee7c2f48d3039255 Reviewed-on: https://pdfium-review.googlesource.com/32152 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-05-07Use checked large integer in ContinueQuickStretchchromium/3424Ryan Harrison
This existing code has the potential for an integer overflow in it. When overflow occurs in this function scaling may partially succeed. This is due to how out of range values are being clamped, which implicitly swallows the overflow. This CL changes the calculation to be performed in a 64-bit space and then attempts to down cast it back to 32-bit space at the end. Because there are multiple steps it is possible for an intermediate value to cause an overflow in 32 bit space, but the final value to be valid. If the downcast is not possible then the stretch operation is failed. An existing test case has been updated, since it encoded an incorrect result. BUG=chromium:839245 Change-Id: I637cc1e2d6c6c2d5394599104f76352c20ead021 Reviewed-on: https://pdfium-review.googlesource.com/32056 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-05-07[xml] Move members to method variables in CFX_XMLParserDan Sinclair
This CL moves several of the member variables to CFX_XMLParser::DoSyntaxParse as they are only used in that method. The names of the members have been updated to make their usage clearer. Change-Id: I460f2bad0181ece278752bd8d93d6bf63dc6d70a Reviewed-on: https://pdfium-review.googlesource.com/32050 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-05-04Check CJBig2_Image is valid before filling.chromium/3423chromium/3422chromium/3421Lei Zhang
Skip a lot of work that will all fail anyway. BUG=chromium:838347 Change-Id: Iba45120e436b5547e106feb27dadea92cc948258 Reviewed-on: https://pdfium-review.googlesource.com/32053 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-05-03Invalidate GIF input buffer when moving file cursor backwardschromium/3420chromium/3419Ryan Harrison
The current implementation of the GIF codec does not handle the file cursor moving backwards correctly. Specifically the input buffer that the data is being read into is not invalidated, so if the entirity of the buffer hasn't been consumed, a chunk of it will be moved to the front before reading in more data, which is just incorrect. Additionally, depending on the specific series of operations, it is possible that the buffer was allocated for more space then had been read into it and the uninitialized portion at the end is being copied to the beginning. The file cursor may move backwards when dealing with an animated gif or other image with multiple frames, since all of the control data is read in on load, and future calls specify what frame to fetch. The code has been changed to treat the input buffer as invalid when moving the cursor to a frame location, which will bypass any of the problematic unused saving behaviour. A call to std::min has been added to prevent allocation of an input buffer larger then the file size. Additionally this CL refactors GifReadMoreData to be clearer about what calculations are occuring, since the existing code reuses a number of vaguely named variables, making it difficult to follow. BUG=chromium:839348, chromium:839361 Change-Id: I2865658187bdf30bcad13ef4cac4f51a8966db11 Reviewed-on: https://pdfium-review.googlesource.com/32054 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-05-03Use strict types in FPDF API, try #3Tom Sepez
Rather than messing with actual inheritence, add type-checking wrappers and just blatantly cast to incomplete types. Along the way, this points out places where we would downcast without checking, which I fix. Change-Id: Ieb303eb46ad8522dfe082454f1f10f247ffd52d5 Reviewed-on: https://pdfium-review.googlesource.com/32030 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-05-03Add CPDF_Page::Extension::GetDocExtension()Tom Sepez
In turn, add CPDF_Document::Extension::GetPDFDoc() so that we can use the abstract return type in more places. Mark an internal-only cpdfxfa_context method as private while we're at it. Change-Id: I08e64f4b9438bf2f731c3a37cf2a41152bbbd8fa Reviewed-on: https://pdfium-review.googlesource.com/31916 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-03Make GetPDFDocument return a CPDF_Docment*, not void*.Tom Sepez
Small oversight. Gets type safety. Change-Id: I669c2c990fdf9013f4bc4835738132ed76e734b8 Reviewed-on: https://pdfium-review.googlesource.com/31991 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-02Convert hand rolled buffer reader in CFX_MemoryStreamRyan Harrison
BUG=pdfium:1007 Change-Id: Ib8aecf2e4833f22a4288f6e1381edc11d114c865 Reviewed-on: https://pdfium-review.googlesource.com/31952 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>