Add -Wtautological-unsigned-zero-compare to BUILD.gn
This may help flag mistakes when converting int to size_t.
-- fix the one unreachable path it uncovered.
Bug: chromium:1195670
Change-Id: I89f8253701f22e38157376aa2c36df6d4b0fecc4
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/89251
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 717c8c3..2b08c61 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -216,6 +216,9 @@
# TODO(crbug.com/1213098): Remove once this is in //build.
cflags += [ "-Wdeprecated-copy" ]
+ # May flag some issues when converting int to size_t.
+ cflags += [ "-Wtautological-unsigned-zero-compare" ]
+
# Catch misuse of cppgc in XFA.
if (pdf_enable_xfa && clang_use_chrome_plugins) {
cflags += [
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index 07b8d5b..17aedfb 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -768,9 +768,6 @@
pdfium::span<const uint8_t> data_span = pAcc->GetSpan();
uint32_t segindex = 0;
for (const auto& index : indices) {
- if (index.start_obj_num < 0)
- continue;
-
FX_SAFE_UINT32 seg_end = segindex;
seg_end += index.obj_count;
seg_end *= total_width;