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

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

https://gcc.gnu.org/g:dad7575e1d2e24ee49f4caea69d67dbafdfbb974

commit r17-5617-gdad7575e1d2e24ee49f4caea69d67dbafdfbb974
Author: Jonathan Wakely <[email protected]>
Date:   Mon Oct 12 10:18:45 2026 +0100

    libstdc++: Fix chrono::time_zone::get_info for very negative times
[PR127815]

    A very negative time point will stay negative when info.begin is
    subtracted from it, which means that a negative value will be passed to
    vector::reserve. That will convert to a huge size_t value, and the
    vector will throw length_error. This commit clamps the time point
    argument to be no less than the start of the zone's first info, so that
    `tp - info.begin` will be non-negative.

    This commit also changes the vector::reserve call to use a size_t
    instead of int, so that if `tp - info.begin` somehow becomes negative
    again due to some future change, we get a very large size_t and then
    std::min<size_t>(100, n * 2) limits that to something which won't throw
    length_error.

    libstdc++-v3/ChangeLog:

            PR libstdc++/127815
            * src/c++20/tzdb.cc (time_zone::_M_get_sys_info): Clamp
            parameter to start of first info. Use unsigned type for argument
            to vector::reserve.
            * testsuite/std/time/time_zone/127815.cc: New test.

    Reviewed-by: Tomasz KamiÅski <[email protected]>

Reply via email to