In ByteStringView.TrimmedRight, there exists a variable that should be
used on the next line, but is not due to a typo. Put the variable to
use. Do the same for the WideStringView version of the test.
Change-Id: If47e56271003d8cfb3e381c967e5a1a97fb3c166
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118073
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
-- use std::array<> where useful.
-- use pdfium::contains() to avoid indexing otherwise.
Change-Id: I7c2ba4c6f71ab6ae94822a711c322ee1658ac82c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118070
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Avoid writing out color values that violate the PDF spec.
Change-Id: I1a7b52407bedfbea443a306906e32236473addbe
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117396
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
This will allow the entire directory to be included into
UNSAFE checks once the format of the paths.txt file matures.
Change-Id: Ia57ebf136e7cdf7ce73928230a223884135a80d9
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117933
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
FPDFPage_Delete() may not work as expected when used in conjunction with
FPDF_SaveAsCopy(). The CPDF_Creator code that saves the PDF does not
understand the structure of the document's page tree. Therefore, it
only looks at references to determine whether to save referenced
objects, or to discard orphaned objects. This becomes a problem when
bookmarks or other objects has references to page objects, as the page
objects are not considered orphaned.
Fix this problem by augmenting the page deletion code in CPDF_Document.
After a page has been deleted, check to see if there are any references
to the page in the page tree. If it is no longer in the page tree,
replace it with an object of type null.
Since it is likely impossible to traverse the entire PDF's object tree
and correctly remove all the references to a page, use the null object
type to null out the page is the best way to effectively remove it,
while preventing references to it from dangling. Objects that become
orphaned as a result of this modification, such as the page content
stream, will be pruned by CPDF_Creator.
Bug: pdfium:2146
Change-Id: I474ff921e2239f27652f5308b56d1c1b74b51d77
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117910
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Use FX_RGB consistently for color representation.
Change-Id: I282232f7eb6b91816af068edd152dccd46364596
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117391
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Consistently use this struct instead of std::array.
Change-Id: I9ccfd55834bc0a118d9e6c937604be6796005522
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117817
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Add a way to represent the RGB channels, with easy access to the color
components.
Change-Id: I051482e9e60ac73d3a1b73e6eeaa8b355d6f34be
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117816
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
The code is already clean with respect to UNSAFE_BUFFERS.
Change-Id: I0076c7ec9210e16cc186119bb4a8f27bd68098f7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117815
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
The code only ever uses the values at [N][1].
-- convert to std::array while at it.
Change-Id: I94ace32fb6b9d936394992619e138620eaef764b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117857
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Currently, this always copies, but we can avoid this in many (not all)
cases with a subsequent CL. There is a slight difference with large
numbers, so this is a check that thing still render properly.
Change-Id: Id4c9d061ed69ca59c5fed0e31cd5feb4574c5e6f
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117331
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Exercise FPDFPage_Delete() followed by FPDF_SaveAsCopy() under a variety
of situations. Show that FPDF_SaveAsCopy() is writing out more data than
necessary.
Bug: pdfium:2146
Change-Id: Ic520acc6a86fbf9b14854e3ba4d2b1ee71fa904b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117770
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Add the nodiscard attribute to CFX_DIBitmap::Create(). Then change all
callers that did not check the return result to do so. Fail gracefully
when it obvious how to do so. Otherwise wrap the Create() call with
CHECK().
Change-Id: Ibab42b2306e8f8a93d8d87472fcec0cb3250df73
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/115412
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
This CL creates a new pdfium_unsafe_buffers_paths.txt in the
top-level directory which lists which sub-directories have been
made safe against C-style pointer arithmetic.
Change-Id: Ibe3e7bc2e3e85e573119a6123c93bc70d91f0330
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117850
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Manual roll to pick up changes related to unsafe-buffers.
e9a12f2766..e5ff2eff3b
Created with:
roll-dep build
Change-Id: I2a464f7205f34cf5870f156d95cb40e034a4fd37
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117810
Auto-Submit: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
-- Suppress enforcement in tests.
-- Also add one missing case in span.h
Change-Id: Ib5a52d858a67545618099bd745a0a173b4a2c2ca
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117811
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Use std::array<float, 3> consistently for color representation.
Also mark some CPDF_MeshStream methods as const.
Change-Id: I0c80cd34d916615b46525d260b1b9501e638f3fa
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117390
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Use pdfium::ClampSub() to avoid undefined behavior in some DrawGouraud()
calculations. The exact result is not critical, as it only affects pixel
values.
Bug: chromium:40813106
Change-Id: I7eaecb1f64fa1c4f46c051280337f0d414a582f0
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117730
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
- Mark some references as const-ref.
- Consolidate repeated calculations.
Change-Id: I459f3602dce352deaf9d61e667967ce0446a98cd
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117710
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Skia no longer supports use of Sfntly as a font subsetter, remove this
unused mention to clarify this.
Change-Id: I08ce184bf3a75de45f4fcc1917719964669514ce
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117690
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
There are all, in fact, 7-bit ASCII.
Change-Id: Ifb063cc983b73ea3acbc5a21c07ff344a9222135
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117630
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Follow-on CL from an offline discussion about "what is char traits
good for?"
Change-Id: Ief99e97e8337b97bcc6816e3168df9835d95e5f9
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117671
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Avoid making ints from string literals. Simplify flow and avoid boolean
state variable `bAll`.
Change-Id: I79d9d03c9fb4884031e32869aff717f40d8f1148
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117672
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Restore the original way that coverage_report.py was calling
subprocess.call(). Before https://pdfium-review.googlesource.com/117451,
the arguments were:
['ninja', ..., 'target1', ..., 'targetN'].
Now, they unintentionally became:
['autoninja', ..., ['target1', ..., 'targetN']].
Remove the extra nested list to avoid Python exceptions from the
subprocess module.
Change-Id: Ieab165b3cc206bff26ee105d5a7b9832ec46a721
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117670
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Synchronize //build_overrides/build.gni with the Chromium file of the
same path and set enable_safe_libstdcxx to true by default. This more
properly reassembles https://crrev.com/1266874 in PDFium.
Bug: pdfium:2144
Change-Id: If20961778d16a8cfacd17de1c256901c0dcd3131
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117650
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Some older Clang compilers get confused by StringTemplate usage in
CPDF_DefaultAppearance's default constructor. Avoid this issue by
removing the default constructor and changing the only caller to use the
1-param ctor instead.
Change-Id: If2b43fdcf94ff5d6f666c83f451f8a9e8fa67339
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117610
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Then remove some wasted padding by converting L"" literals to "".
-- Fixes botch in CharEncodingFromString() where `== 0` was missing.
Change-Id: Ia1647cf7db6e6f073f35d9560b89d751dd1e92f1
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117551
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
pdfium::span<> should be constexpr-enough to use here. Then use
a range-based for loop and avoid C-style indexing.
Change-Id: Idc36e51f390be10d42dc57ee9af2c66736276d86
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117530
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Clang's inability to optimize out some redundant CHECK()s was noticed
while working on an unrelated CL. This is caused by the issue noted in
crbug.com/40836910, where __attribute__((annotate()) changed code gen
as a side effect of placating warnings in the plugin.
Bug: chromium:40836910
Change-Id: Idde4cecd3c329c4c7bac728d5c376a4574cd8f77
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117550
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Prepare for using the clang plugin-based filtering mechanism for
unsafe buffer warnings. This is enabled automatically as appropriate in
build/config/clang/BUILD.gn (sync'ed from outside of pdfium repository
along with other tools). It is enabled on a directory-by-directory basis
based on some paths.txt file (location to be specified via a GN variable
following a build/ roll past https://crrev.com/c/5369835.
Change-Id: I030dc5d15b2b9ea0541af146bcce5d61df13ffee
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117510
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Save the CPDF_Page pointer passed into the CPDF_AnnotList ctor and reuse
it, instead of making the caller pass it in multiple times.
Change-Id: I4222e51343dc3f82ab4c2d59ecc9b986b8bfe3ae
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117454
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Even better, remove the unsafe pointer arithmetic being performed on
these results.
Change-Id: I692dd13c43af59c636f0b2b12dd0ac356ea18fd7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117492
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Incur the complexity of UNSAFE_BUFFERS() in order to bypass the same
checks that were just made being performed via span<>::subspan(). This
should be optimized out on official builds, but debug builds are still
slower.
Change-Id: I2bac2928f28b35dd71e569ce66f991b67918cdd4
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117292
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>