Add -Wlifetime-safety-permissive flag and fix CPDF_DIB lifetime warning. [pdfium : main]

0 views
Skip to first unread message

Tom Sepez (Gerrit)

unread,
Jun 22, 2026, 3:12:20 PM (3 days ago) Jun 22
to Lei Zhang, pdfium-...@googlegroups.com
Attention needed from Lei Zhang

Tom Sepez voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Lei Zhang
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: pdfium
Gerrit-Branch: main
Gerrit-Change-Id: I660ef01bdc7bc98a60eb0c1fb884062a824f943e
Gerrit-Change-Number: 150450
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Sepez <tse...@chromium.org>
Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
Gerrit-Attention: Lei Zhang <the...@chromium.org>
Gerrit-Comment-Date: Mon, 22 Jun 2026 19:12:10 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Lei Zhang (Gerrit)

unread,
Jun 22, 2026, 5:07:26 PM (3 days ago) Jun 22
to Tom Sepez, Lei Zhang, pdfium...@luci-project-accounts.iam.gserviceaccount.com, pdfium-...@googlegroups.com
Attention needed from Tom Sepez

Lei Zhang voted and added 2 comments

Votes added by Lei Zhang

Code-Review+1

2 comments

Commit Message
Line 9, Patchset 2 (Latest):Enable the -Wlifetime-safety-permissive compiler flag to enforce
Lei Zhang . unresolved

Is there a bug report tasked with enabling this in Chromium as well? i.e. Will the BUILD.gn change become redundant at some point if this gets enabled by default in //build?

File core/fpdfapi/page/cpdf_dib.h
Line 133, Patchset 2 (Latest): mutable DataVector<uint8_t> src_buf_;
Lei Zhang . unresolved

Maybe a slightly more descriptive name like "src_remainder_buf_"?

Open in Gerrit

Related details

Attention is currently required from:
  • Tom Sepez
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: pdfium
Gerrit-Branch: main
Gerrit-Change-Id: I660ef01bdc7bc98a60eb0c1fb884062a824f943e
Gerrit-Change-Number: 150450
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Sepez <tse...@chromium.org>
Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
Gerrit-Attention: Tom Sepez <tse...@chromium.org>
Gerrit-Comment-Date: Mon, 22 Jun 2026 21:07:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Tom Sepez (Gerrit)

unread,
Jun 22, 2026, 6:26:35 PM (2 days ago) Jun 22
to Lei Zhang, pdfium...@luci-project-accounts.iam.gserviceaccount.com, pdfium-...@googlegroups.com

Tom Sepez voted and added 2 comments

Votes added by Tom Sepez

Commit-Queue+2

2 comments

Commit Message
Line 9, Patchset 2:Enable the -Wlifetime-safety-permissive compiler flag to enforce
Lei Zhang . resolved

Is there a bug report tasked with enabling this in Chromium as well? i.e. Will the BUILD.gn change become redundant at some point if this gets enabled by default in //build?

Tom Sepez

Maybe. Didn't see an open on for Chrome, only V8, filed one for PDFium

File core/fpdfapi/page/cpdf_dib.h
Line 133, Patchset 2: mutable DataVector<uint8_t> src_buf_;
Lei Zhang . resolved

Maybe a slightly more descriptive name like "src_remainder_buf_"?

Tom Sepez

Done

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: pdfium
    Gerrit-Branch: main
    Gerrit-Change-Id: I660ef01bdc7bc98a60eb0c1fb884062a824f943e
    Gerrit-Change-Number: 150450
    Gerrit-PatchSet: 5
    Gerrit-Comment-Date: Mon, 22 Jun 2026 22:26:31 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Lei Zhang <the...@chromium.org>
    satisfied_requirement
    open
    diffy

    pdfium-scoped@luci-project-accounts.iam.gserviceaccount.com (Gerrit)

    unread,
    Jun 22, 2026, 7:05:29 PM (2 days ago) Jun 22
    to Tom Sepez, Lei Zhang, pdfium-...@googlegroups.com

    pdfium...@luci-project-accounts.iam.gserviceaccount.com submitted the change with unreviewed changes

    Unreviewed changes

    2 is the latest approved patch-set.
    The change was submitted with unreviewed changes in the following files:

    ```
    The name of the file: core/fpdfapi/page/cpdf_dib.cpp
    Insertions: 6, Deletions: 6.

    @@ -1091,9 +1091,9 @@
    }

    uint32_t src_pitch_value = src_pitch.value();
    - // A fallback member buffer (src_buf_) is used as the backing store for
    - // `pSrcLine` when the stream is truncated and the remaining bytes count
    - // is less than `src_pitch_value`.
    + // A fallback member buffer is used as the backing store for `pSrcLine`
    + // when the stream is truncated and the remaining bytes count is less
    + // than `src_pitch_value`.
    pdfium::span<const uint8_t> pSrcLine;

    if (cached_bitmap_ && src_pitch_value <= cached_bitmap_->GetPitch()) {
    @@ -1109,9 +1109,9 @@
    if (remaining_bytes.size() >= src_pitch_value) {
    pSrcLine = remaining_bytes.first(src_pitch_value);
    } else {
    - src_buf_ = DataVector<uint8_t>(src_pitch_value);
    - fxcrt::Copy(remaining_bytes, src_buf_);
    - pSrcLine = src_buf_;
    + src_remainder_buf_ = DataVector<uint8_t>(src_pitch_value);
    + fxcrt::Copy(remaining_bytes, src_remainder_buf_);
    + pSrcLine = src_remainder_buf_;
    }
    }

    ```
    ```
    The name of the file: core/fpdfapi/page/cpdf_dib.h
    Insertions: 1, Deletions: 1.

    @@ -130,7 +130,7 @@
    std::vector<DIB_COMP_DATA> comp_data_;
    mutable DataVector<uint8_t> line_buf_;
    mutable DataVector<uint8_t> mask_buf_;
    - mutable DataVector<uint8_t> src_buf_;
    + mutable DataVector<uint8_t> src_remainder_buf_;
    RetainPtr<CFX_DIBitmap> cached_bitmap_;
    // Note: Must not create a cycle between CPDF_DIB instances.
    RetainPtr<CPDF_DIB> mask_;
    ```

    Change information

    Commit message:
    Add -Wlifetime-safety-permissive flag and fix CPDF_DIB lifetime warning.


    Enable the -Wlifetime-safety-permissive compiler flag to enforce
    lifetime safety checks.

    Fix a lifetime issue in CPDF_DIB::GetScanline where a pointer to a
    local temporary buffer could be returned when the stream is truncated.
    The temporary buffer is replaced with a class member buffer.

    The code path returning the temporary buffer is believed to be
    dynamically unreachable. It requires a JPX image with less than 3
    channels to trigger a width mismatch, but such images are forced to
    the DeviceGray color space, which routes differently.

    TAG=agy
    CONV=35e67fbe-02d2-429f-9dbd-5e7fa8e5e9b6
    Fixed: 526724013
    Change-Id: I660ef01bdc7bc98a60eb0c1fb884062a824f943e
    Commit-Queue: Tom Sepez <tse...@chromium.org>
    Reviewed-by: Lei Zhang <the...@chromium.org>
    Files:
    • M BUILD.gn
    • M core/fpdfapi/page/cpdf_dib.cpp
    • M core/fpdfapi/page/cpdf_dib.h
    Change size: S
    Delta: 3 files changed, 11 insertions(+), 7 deletions(-)
    Branch: refs/heads/main
    Submit Requirements:
    • requirement satisfiedCode-Review: +1 by Lei Zhang
    Open in Gerrit
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: merged
    Gerrit-Project: pdfium
    Gerrit-Branch: main
    Gerrit-Change-Id: I660ef01bdc7bc98a60eb0c1fb884062a824f943e
    Gerrit-Change-Number: 150450
    Gerrit-PatchSet: 6
    Gerrit-Owner: Tom Sepez <tse...@chromium.org>
    Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
    Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
    open
    diffy
    satisfied_requirement
    Reply all
    Reply to author
    Forward
    0 new messages