https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127038

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jorgen Kvalsvik <[email protected]>:

https://gcc.gnu.org/g:5da256175a9f7a5f82afcd475ac71eb5c065fac8

commit r17-3811-g5da256175a9f7a5f82afcd475ac71eb5c065fac8
Author: Jørgen Kvalsvik <[email protected]>
Date:   Tue Sep 1 14:14:13 2026 +0200

    Check past-the-end before dereferencing iterator

    Guard the dereference in the case where the current cursor in the
    needle isn't a tombstone in case we're at the end of the
    haystack. Example pair:

      NEEDLE:   6 x x 4 6
      HAYSTACK: 4 6 x x 4

    We find the subsequence 6 4, but the needle is not yet at end (missing
    6) while the haystack is moved past the end:

      NEEDLE:   6 x x 4 6
                        ^
      HAYSTACK: 4 6 x x 4
                          ^

    If the haystack (super) is exhausted before the needle (sub) we know
    it isn't a proper subsequence, so this is the correct behaviour.

    This example was in the testsuite and caught by ASAN.

            PR gcov-profile/127038

    gcc/ChangeLog:

            * gcov.cc (tombstone_subsequence_p): Guard iterator
            dereference.

Reply via email to