summaryrefslogtreecommitdiff
path: root/core/fxcodec
AgeCommit message (Collapse)Author
2018-07-06Fix regression in CJBig2_TRDProc.chromium/3486chromium/3485chromium/3484Lei Zhang
Commit 7695dd0f mistakenly changed a signed integer to unsigned. This is incorrect because right shifts for negative integers behave differently. BUG=chromium:859284 Change-Id: Id9c54848b15ace1de080c174f261dd2c064018e0 Reviewed-on: https://pdfium-review.googlesource.com/37230 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-02Check for more integer overflows in CJBig2_TRDProc.Lei Zhang
BUG=chromium:859284 Change-Id: I41ce5de4cca0a863dc6e60b64fd69d36c2672a64 Reviewed-on: https://pdfium-review.googlesource.com/36790 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-06-29Use pdfium::span with CPDF_IccProfile and friends.Lei Zhang
Change-Id: I88d3e86a1dad75ef9c6bfb3401af6606479031a7 Reviewed-on: https://pdfium-review.googlesource.com/36634 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-06-29Remove out param from CCodec_IccModule::CreateTransform_sRGB().Lei Zhang
Its return value contains the same data. Change-Id: I2bf4e72faf978e5d491bec573babc8099cda4e5a Reviewed-on: https://pdfium-review.googlesource.com/36633 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-06-29Add ScopedCmsProfile.Lei Zhang
Using this unique_ptr avoids the need for explicit cmsCloseProfile() calls in CCodec_IccModule::CreateTransform_sRGB(). Change-Id: I5b2d5d9800ea344aceb0ed5c6b745a2925bab9c9 Reviewed-on: https://pdfium-review.googlesource.com/36632 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-06-29Clean up CLcmsCmm.Lei Zhang
Make members const and private. Fix nits. Change-Id: I945bc26438f8fbd6904dc1b15513ab9e51170dc7 Reviewed-on: https://pdfium-review.googlesource.com/36631 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-06-29Delete dead code in CCodec_IccModule.Lei Zhang
Change-Id: I711654cfb1ab43a5d17afbe6f877c1860dd1b7f0 Reviewed-on: https://pdfium-review.googlesource.com/36630 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-06-29Better determine if ICC colorspaces can be used for blending.Lei Zhang
Implement CPDF_ColorSpace::IsNormal() and check it when rendering. While IsNormal() is trivial for most colorspaces, it needs to be implemented separately for ICC colorspaces. This fixes a rendering regression from commit 1c0de38c. BUG=chromium:847346 Change-Id: Iaafed3f8ee40b26ac2cbfbdf2251407f7935311b Reviewed-on: https://pdfium-review.googlesource.com/36571 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-06-29Limit image size in CJBig2_PDDProc.Lei Zhang
CJBig2_PDDProc internally creates a CJBig2_GRDProc to create an image. If the image is too big, then processing it can use up too much memory. BUG=chromium:857106 Change-Id: I06a9eaed6941be1cbb7481d21048e6a1681696b7 Reviewed-on: https://pdfium-review.googlesource.com/36490 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-06-29Clean up CJBig2_PDDProc.Lei Zhang
Change-Id: Ia83ac5dae0dedf55f1b0f0cf2a728c64474f72db Reviewed-on: https://pdfium-review.googlesource.com/36450 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-06-28Use unique_ptr in ccodec_tiffmodule.cppTom Sepez
Change-Id: I9c829a09a1c5ecdf011b1a9804a65e77b0e199b7 Reviewed-on: https://pdfium-review.googlesource.com/36371 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-06-28Use spans and std::unique_ptrs in fx_codec_flate.cppTom Sepez
Also avoid needless use of void* in place of actual type. Also free context with free function corresponding to its allocator, in case the m_ functions change down the road. Change-Id: I384f6b309c2522eb0faafbe73b94cc3bf582dbb8 Reviewed-on: https://pdfium-review.googlesource.com/36370 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-06-27Remove unused m_bGif* fields from CFX_DIBAttributeTom Sepez
Two are completely unused, and two are set but never referenced. Change-Id: I0173123e33a4240aef9ed24aaee9e1df6cf9aa0a Reviewed-on: https://pdfium-review.googlesource.com/36290 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-27Use spans and UnownedPtrs in cjpx_decoder.hTom Sepez
Change-Id: I1c9f8221ce7a0e42407e93deec481be2e941cfde Reviewed-on: https://pdfium-review.googlesource.com/36210 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-20Add in a size guard to JPX fuzzerRyan Harrison
Setting an upper limit to the size of images being processed in the JPX fuzzer to reduce timeouts due to images just being really big. Also cleaned the types for passing pitch down to reduce the signedness conversions. BUG=chromium:834561 Change-Id: I28b7a2537a922ed7a9ca2f8ed049ae78dd471f49 Reviewed-on: https://pdfium-review.googlesource.com/35570 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-06-14Merge 3 methods of CJBig2_GRDProc togetherchromium/3465chromium/3464chromium/3463chromium/3462chromium/3461Nicolas Pena
This CL merges 3 methods into a single DecodeArithOpt3(). The code is the same, except for some constants which are extracted out as namespace variables. Change-Id: I6d9127d71b5e7c4c75e31a736b0f3307bb78a076 Reviewed-on: https://pdfium-review.googlesource.com/35170 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-06-13Make CJBig2_Context::GetHuffmanTable return constNicolas Pena
This CL changes GetHuffmanTable() to return a const pointer and fixes other members / functions accordingly. Change-Id: Ie62fe044b3156f67885dd4fa1f6512cbd35a83d3 Reviewed-on: https://pdfium-review.googlesource.com/35116 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-06-13Remove CFX_FixedBufGrow from fx_codec_icc.cppNicolas Pena
Bug: pdfium:177 Change-Id: Ib4de4f258ebd98a53b309c30b7e4aa28f0c581eb Reviewed-on: https://pdfium-review.googlesource.com/35112 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-11Remove explicit calls to x->operator[]Tom Sepez
Because its a code smell of a sort. Change-Id: Id1c1b124f539e31a929701fb9486da9d396d3563 Reviewed-on: https://pdfium-review.googlesource.com/34695 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-05Further improve CCodec_FaxDecoder performance in debug builds.Lei Zhang
BUG=chromium:845117 Change-Id: Id1c97bc40ff776f52011a8ab2d6e5166cd7c64c8 Reviewed-on: https://pdfium-review.googlesource.com/33650 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-28Revert 'Remove almost all usages of CFX_FixedBufGrow with std::vector'chromium/3444Nicolas Pena
This is a manual revert of the CL at: https://pdfium-review.googlesource.com/c/pdfium/+/32159 The only file manually changed was cpdf_renderstatus.cpp Reason for revert: the bug below shows that sometimes the vector size used is larger than the parameter given to CFX_FixedBufGrow. Thus, we will revert, then add vectors using std::max unless it's clear from the code that the code will never access indices outside. Bug: chromium:847247 Change-Id: Iee54af023c8564824418a7d34a6385b0bc418ff0 Reviewed-on: https://pdfium-review.googlesource.com/33050 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-05-25Replace some #ifdef PDF_ENABLE_XFA with runtime checks.Tom Sepez
Abstract GetUserPermissions() differences via new virtual method. Abstract GetPageCount() differences via existing virtual method. Remove unused ReadHeader() form for non-xfa. Remove unused FindSubstFontByUnicode() for xfa. Remove unused FXFONT_EXACTMATCH Change-Id: I0a3de01a9841db86fcbc96991d3fa2682393b9ad Reviewed-on: https://pdfium-review.googlesource.com/32831 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-05-24Do some variable cleanup in CJBig2_ContextNicolas Pena
This CL cleans up variables in CJBig2_Context. It moves some declarations further, to when the variables are actually used. It also caches huffman tables in a vector of unique_ptr. Change-Id: Id3af96f9526b1000f681e4e2b174bba07b45ee55 Reviewed-on: https://pdfium-review.googlesource.com/32715 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-05-22Remove JBIG2_memcpy() and JBIG2_memset().Lei Zhang
Just use memcpy() and memset(). Change-Id: Id6c6fab4e65a5524786ae318270c5981313825f2 Reviewed-on: https://pdfium-review.googlesource.com/32743 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-05-22Remove return value from CJBig2_Image::SetPixel().Lei Zhang
Nobody reads it. Change-Id: I76c0f5881e5432d2086cb8eaec7fc70fa5b71536 Reviewed-on: https://pdfium-review.googlesource.com/32741 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-05-22Fix method style in JBig2_Image.Lei Zhang
Rename fooBar() to FooBar(). Change-Id: I87775fa14ce7e4f4a5897780d0d02fb61c7693ff Reviewed-on: https://pdfium-review.googlesource.com/32739 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-05-21Avoid indexing into std::vector inside a tight loop.chromium/3437Lei Zhang
In CCodec_FaxDecoder::v_GetNextLine(), a fixed size vector often needs to be inverted. Doing so without checking bounds on every access makes a big difference in non-optimized builds. BUG=chromium:843899 Change-Id: Iecc0a3da22631a289745245563dab7a7c3c458d0 Reviewed-on: https://pdfium-review.googlesource.com/32744 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-17Expose CJBig2_Image::ComposeTo() as a public method.Lei Zhang
CJBig2_Image::ComposeFrom() wraps a call to ComposeTo() and does an extra validity check. In tight loops where the validity check will always succeed, this is wasteful. Change existing callers of ComposeFrom() to ComposeTo() when the validity check has already been done. BUG=chromium:840728 Change-Id: I39fb42eea49b92b7804cbd42c3d8a0329edeb58d Reviewed-on: https://pdfium-review.googlesource.com/32637 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-05-17Consolidate identical code in CJBig2_TRDProc.Lei Zhang
Change-Id: Ib44a6b7bd19625a4081322d2471551bec894abd8 Reviewed-on: https://pdfium-review.googlesource.com/32638 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-17Update third_party/base/compiler_specific.h.Lei Zhang
Import Chromium's base/compiler_specific.h from r537069. Now that FALLTHROUGH is available via compiler_specific.h, remove FX_FALLTHROUGH. Change-Id: I8b9631a4f007673e10e0c26951dfd61e9dcada30 Reviewed-on: https://pdfium-review.googlesource.com/32639 Reviewed-by: Nico Weber <thakis@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-16Move JBig2 HuffmanTables into JBig2_HuffmanTable.cppNicolas Pena
This CL changes the table information so it can be indexed, and allows moving all of the information to the CJBig2_HuffmanTable implementation, which is the only real user of the data. Change-Id: I88780bee32c8509198518fd3b1e82d68ae7ff707 Reviewed-on: https://pdfium-review.googlesource.com/32635 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-05-16Remove some more unused #definesTom Sepez
Bug: pdfium:1085 Change-Id: I62c526ae865f0cadfddd2e75a616bce73de0f88d Reviewed-on: https://pdfium-review.googlesource.com/32632 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-05-16Do more optimizations to make FindBit() faster.chromium/3433Lei Zhang
Change-Id: Ibbc020393e38405f9d1cb0d483ef875777d4e721 Reviewed-on: https://pdfium-review.googlesource.com/32650 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-16Avoid a memset() in FindBit() in the fax codec.Lei Zhang
FindBit() is called frequently by other fax codec code. Use 16 more bytes of space to store the two possible values memset() can set. Change-Id: Ibeb549c44928bbb468ac4eb4cef2d9339cf6490d Reviewed-on: https://pdfium-review.googlesource.com/32630 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-15Lower the limit of image dimensions for fax codecs.chromium/3432Lei Zhang
Use the same limit as JBIG2 codecs. BUG=chromium:834633 Change-Id: I11d12c841e10ab48fd85df792bf8a034fe40493c Reviewed-on: https://pdfium-review.googlesource.com/32514 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-05-15Read data in bigger chunks in fax codec code.Lei Zhang
In case there are long runs of data to be skipped, FindBit() runs much faster reading and comparing 8 bytes at a time. BUG=chromium:834633 Change-Id: Ifc7b348d123c5a72cf09fbf53d764075f8abfba0 Reviewed-on: https://pdfium-review.googlesource.com/32513 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@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-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-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-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-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-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-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-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-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>