summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_edit
AgeCommit message (Collapse)Author
2016-09-28Use string pools in some dictionaries, names, and strings.tsepez
BUG=pdfium:597 Review-Url: https://codereview.chromium.org/2345063002
2016-09-21Remove some objnum locals with AddIndirectObjecttsepez
Also, it's idempotent, so simplify some logic in callers to not care if objnum is zero. The alternate forms are rarely used, using the objnum form makes it clear that SetReferenceFor() can't possibly register the object as a side-effect. Review-Url: https://codereview.chromium.org/2361713002
2016-09-21Use unique_ptr<CPDF_Object, ReleaseDeleter<>> in more placeschromium/2868tsepez
Review-Url: https://codereview.chromium.org/2358243002
2016-09-20Make CPDF_Array not do indirect object creation.tsepez
We remove the indirect object holder argument and check that call sites pass ownable objects, adding a reference in one place that always was passing an indirect object. Also check that the invariant isn't violated, we need to fail here in the wild and investigate -- these are existing UAFs. Review-Url: https://codereview.chromium.org/2355083002
2016-09-20CPDF_Document friend cleanupdsinclair
Remove CPDF_Creator and CPDF_Parser as friends of CPDF_Document. Move all member variables to the private section, and add CPDF_TestDocument as a private friend. Review-Url: https://codereview.chromium.org/2349353003
2016-09-20Re-land "Make CPDF_IndirectObjectHolder use unique_ptr to objects""tsepez
This reverts commit 81e1e3fd2d33478733e47bd007b76fac1a663e74. Review-Url: https://codereview.chromium.org/2353013003
2016-09-19Revert "Make CPDF_IndirectObjectHolder use unique_ptr to objects"Tom Sepez
This reverts commit c8544d634a1993e2592e41458be215fcd0956031. TBR=dsinclair@chromium.org Review URL: https://codereview.chromium.org/2355683002 .
2016-09-19Make CPDF_IndirectObjectHolder use unique_ptr to objectstsepez
The objects it is given are owned by it and are simply deleted without regard to Release() used by others. Review-Url: https://codereview.chromium.org/2350263002
2016-09-19Clean up CPDF_Stream.tsepez
Replace the CPDF_Stream(nullptr, 0, nullptr) pattern with a default ctor. Remove unused parameters from CPDF_Stream::SetData(). Both are always passed as FALSE. CPDF_Stream declared its own m_GenNum, which shadowed the one in CPDF_Object. It was used only to distinguish file/memory streams, so add a bool explicitly for this purpose. Remove the union, it would be sad if we confused user data with a C++ object with virtual function calls. Use unique_ptrs with appropriate deleters to manage memory. Review-Url: https://codereview.chromium.org/2347993002
2016-09-15Rename dictionary set and get methodsdsinclair
This Cl makes the Get and Set methods consistenly use {G|S}et<Type>For. BUG=pdfium:596 Review-Url: https://codereview.chromium.org/2334323005
2016-08-23Make indirect object holder private.dsinclair
This CL moves the m_IndirectObjs map to be private to the IndirectObjectHolder. Various bits of code have been updated to use the accessors to the map. This CL fixes the issue with the last time this landed by removing the objnum check from GetIndirectObject() which appears to have caused the crashes. Review-Url: https://codereview.chromium.org/2275703002
2016-08-23IndirectObjectHolder API updatesdsinclair
This Cl updates the names of the methods in the indirect object holder to better reflect their usage. The m_LastObjNum is made private and a setter added. Review-Url: https://codereview.chromium.org/2275593002
2016-08-22Revert of Move parser pointer to CPDF_Document (patchset #6 id:100001 of ↵dsinclair
https://codereview.chromium.org/2253723002/ ) Reason for revert: Causing asan issues. See crbug.com/639451. Original issue's description: > Move parser pointer to CPDF_Document > > The CPDF_IndirectObjectHolder has two subclasses, CPDF_Document and > CFDF_Document. The CPDF document requires the parser and the CFDF document > does not. This cl moves the parser pointer up to CPDF_Document. > > Committed: https://pdfium.googlesource.com/pdfium/+/260f5fbf3553a96fa49b029cc050220039c30e2a TBR=tsepez@chromium.org,thestig@chromium.org # Not skipping CQ checks because original CL landed more than 1 days ago. Review-Url: https://codereview.chromium.org/2266033002
2016-08-17Move parser pointer to CPDF_Documentdsinclair
The CPDF_IndirectObjectHolder has two subclasses, CPDF_Document and CFDF_Document. The CPDF document requires the parser and the CFDF document does not. This cl moves the parser pointer up to CPDF_Document. Review-Url: https://codereview.chromium.org/2253723002
2016-08-09Fix a leak with FPDFPageObj_NewImgeObj().thestig
BUG=pdfium:545 Review-Url: https://codereview.chromium.org/2194393002
2016-08-05Add CPDF_ImageObject::GetImage().thestig
And use it where appropriate. Review-Url: https://codereview.chromium.org/2224623002
2016-07-15Use CPDF_Dictionary::SetAtReference instead of CPDF_Dictionary::AddReference.jaepark
The definitions of CPDF_Dictionary::SetAtReference and CPDF_Dictionary::AddReference are identical, and AddReference is only used once. So remove CPDF_Dictionary::AddReference method and use CPDF_Dictionary::SetAtReference instead. Review-Url: https://codereview.chromium.org/2161453002
2016-06-13Make code compile with clang_use_chrome_plugin (part I)weili
This change contains files in core/fpdfapi directory. This is part of the efforts to make PDFium code compilable by Clang chromium style plugins. The changes are mainly the following: -- move inline constructor/destructor of complex class/struct out-of-line; -- add constructor/destructor of complex class/struct if not explicitly defined; -- add explicit out-of-line copy constructor when needed; -- move inline virtual functions out-of-line; -- Properly mark virtual functions with 'override'; -- some minor cleanups; BUG=pdfium:469 Review-Url: https://codereview.chromium.org/2060973002
2016-06-07Get rid of NULLs in core/thestig
Review-Url: https://codereview.chromium.org/2032613003
2016-06-07Add missing const to CPDF_Stream::InitStream()tsepez
Review-Url: https://codereview.chromium.org/2044453003
2016-06-06Remove unused PS generation code.thestig
CFX_PSRenderer, IFX_PSOutput, CPSOutput, CPSPrinterDriver. Also reland commit 2d63eaa. Review-Url: https://codereview.chromium.org/2019603002
2016-06-02Fix all the code which has duplicate variable declarationsweili
When there are duplicate variable declarations, the inner names shadow the outter ones. This is error prone and harder to read. Remove all the instances found by /analyze. BUG=chromium:613623, chromium:427616 Review-Url: https://codereview.chromium.org/2027273002
2016-05-23Delete CPDF_Object::IsModified().thestig
Review-Url: https://codereview.chromium.org/2001933002
2016-05-17Fix DrMemory bot error by properly initializing the variableweili
The variable needs to be initialized before using. Review-Url: https://codereview.chromium.org/1984323002
2016-05-17Revert of Remove an unnecessary variable from CPDF_Creator (patchset #1 ↵weili
id:20001 of https://codereview.chromium.org/1988603002/ ) Reason for revert: The variable is still needed, will fix the other way. Original issue's description: > Remove an unnecessary variable from CPDF_Creator > > The variable may not be initialized before using, which caused > errors on DrMemory bot. Since it is not necessary, remove it. > > TBR=thestig@chromium.org > > Committed: https://pdfium.googlesource.com/pdfium/+/47b998b53edbb071bb55c909169be1070126fb22 TBR=dsinclair@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/1987783002
2016-05-17Remove an unnecessary variable from CPDF_Creatorweili
The variable may not be initialized before using, which caused errors on DrMemory bot. Since it is not necessary, remove it. TBR=thestig@chromium.org Review-Url: https://codereview.chromium.org/1988603002
2016-05-16Clean up CPDF_Creator.thestig
- Used unique_ptr and initializer list. - Remove variables that never change in value. Review-Url: https://codereview.chromium.org/1976003003
2016-04-27Standardize on ASSERT.dsinclair
There are currently three ways to assert in the code (ASSERT, FXSYS_assert and assert). This CL standardizes on ASSERT. The benefit of ASSERT is that it can be overridden if the platform requies and we can pickup the Chromium version if it has already been defined in the build. This does change behaviour. Currently FXSYS_assert is always defined but ASSERT is only defined in debug builds. So, the FXSYS_assert's would fire in Release builds. That will no longer happen. BUG=pdfium:219 Review-Url: https://codereview.chromium.org/1914303003
2016-04-26Move CPDF_Document code into cpdf_document.cpp.thestig
Review URL: https://codereview.chromium.org/1925453002
2016-04-26Remove several IPDF_ interfaces and CPDF_RenderModule.dsinclair
This CL removes the interfaces: * IPDF_ObjectRenderer * IPDF_OCContext * IPDF_RenderModule * IPDF_PageModule The CPDF_RenderModule was just wrapping new and delete calls. This Cl moves those up to the callers and removes the CPDF_RenderModule class. Review URL: https://codereview.chromium.org/1918323003
2016-04-26Clean up CPDF_Page.thestig
- Merge CPDF_Page::Load() into ctor. - Remove always nullptr param for CPDF_Page::ParseContent(). - Remove unneeded indirection in IPDF_RenderModule. - Delete CPDF_ParseOptions. - Fix up CPDF_Pattern. Review URL: https://codereview.chromium.org/1918113002
2016-04-21Remove next batch of CFX_ arrays from fpdf_edit_doc.cpptsepez
Review URL: https://codereview.chromium.org/1904303002
2016-04-21Remove more CFX_ArrayTemplate from fpdf_edit_doc.cpptsepez
Review URL: https://codereview.chromium.org/1909213002
2016-04-21Replace CFX_ArrayTemplate with std::vector in CPDF_ObjectStreamtsepez
Replace two parallel arrays with an array of pairs. Several methods always returned same value, make void instead. Review URL: https://codereview.chromium.org/1908153002
2016-04-20Cleanups from prior CLs.dsinclair
This cleans up the Initialize methods and the ownership in CPDF_Creator. Review URL: https://codereview.chromium.org/1902713003
2016-04-19Remove IPDF_CryptoHandler and IPDF_SecurityHandler.dsinclair
This CL replaces the interfaces with the concrete classes. The concrete classes are also renamed to remove the Standard from their names. BUG=pdfium:468 Review URL: https://codereview.chromium.org/1898173002
2016-04-15Avoid narrowing to StringC in CPDF_Name and CPDF_NameTreetsepez
Remove redundant CPDF_Name constructors given promotion rules. Rework one char* in CPDF_PageContentGenerator. Review URL: https://codereview.chromium.org/1890973006
2016-04-14Explicity use CFX_ByteStrings in a couple of placestsepez
These are exposed by making the ByteString from ByteStringC ctor explicit, but we can clean them up independently. Review URL: https://codereview.chromium.org/1884363002
2016-04-14Make CPDF_Dictionary methods take CFX_ByteString argumentstsepez
This will help avoid duplicate allocation of CFX_ByteStrings when the caller already has one. It may seem counter-intuitive that requiring the caller to pass an allocated CFX_ByteString rather than a static CFX_ByteStringC would improve the situation, but due to the idiosyncrasies of std::map, the CPDF_Dictionary methods must always do an allocation under the covers which can't be avoided. The changed callers in this CL are places where we would previously demote to CFX_ByteStringC and then allocate a a duplicate CFX_ByteString in the dictionary method. Review URL: https://codereview.chromium.org/1889863002
2016-04-13Re-enable warning 4701 for GN build and some cleanupweili
Clean up three 4701 warnings (use potientially uninitialized variable) which are the only ones left; Re-enable warning 4701 for GN build; Remove an unused data structure; BUG=pdfium:29 Review URL: https://codereview.chromium.org/1885093002
2016-04-11Use std::vector as internal storage for CPDF_ArrayWei Li
Replace the usage of CFX_ArrayTemplate inside CPDF_Array, which has non-standard APIs such as GetSize() returns int. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1867183002 .
2016-04-08Make converstion explicit from CFX_ByteString to uint8_t*tsepez
BUG= Review URL: https://codereview.chromium.org/1868293002
2016-04-08Rename both As{Byte,Wide}StringC() helpers to AsStringC().tsepez
The naming is redundant given the base type, and will stand in the way of consolidating Byte and Wide code. BUG= Review URL: https://codereview.chromium.org/1862123003
2016-04-04Make down-conversion explicit from CFX_ByteString to CFX_ByteStringC.tsepez
Having this happen implicitly can be dangerous because the lifetime has to be considered; we should have caught the "red bots" in https://codereview.chromium.org/1847333004/#ps60001 at compile time. Review URL: https://codereview.chromium.org/1853233002
2016-03-29Code change to avoid signed/unsigned mismatch warnings.Wei Li
This makes pdfium code on Linux and Mac sign-compare warning free. The warning flag will be re-enabled after checking on windows clang build. BUG=pdfium:29 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1841643002 .
2016-03-29Rename GetElementValue() to GetDirectObject{By,At}().tsepez
Every time I read this code, I have to make the mental substituion that "Element value" means "de-ref indirect object", so it might as well just say so. BUG= Review URL: https://codereview.chromium.org/1841173002
2016-03-25Remove FX_DWORD from core/ and delete definitionchromium/2695chromium/2694chromium/2693chromium/2692tsepez
Review URL: https://codereview.chromium.org/1832173003
2016-03-25Replace CFX_DWordArray with CFX_ArrayTemplate<FX_DWORD>.Tom Sepez
First step to getting rid of FX_DWORD. R=ochang@chromium.org Review URL: https://codereview.chromium.org/1832113003 .
2016-03-24Added bounds checking to GetNameFromTT to handle corrupt files.Tom Sepez
Patch by forshaw. This patch adds bounds checking to the names buffer passed to GetNameFromTT. There are observed crashes in this function where data is read outside of the bounds allocated and passed to GetNameFromTT. There's no reason that this function should ever try and read outside of the allocated bounds. BUG=583037 TBR=forshaw@chromium.org patch from issue 1829013002 at patchset 40001 (http://crrev.com/1829013002#ps40001) Review URL: https://codereview.chromium.org/1830243003 .
2016-03-23Split core/include/fpdfapi/fpdf_resource.hdan sinclair
This CL splits apart the core/include/fpdfapi/fpdf_resource.h file and places the classes into individual files. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1824033002 .