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

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

https://gcc.gnu.org/g:7099a54b01a0cd04247fe88e3545916ab5ee0d22

commit r17-5419-g7099a54b01a0cd04247fe88e3545916ab5ee0d22
Author: Harald Anlauf <[email protected]>
Date:   Tue Oct 20 20:29:19 2026 +0200

    fortran: Prevent gfc_copy_expr() truncating strings containing NUL
[PR127892]

    gfc_copy_expr() would create a truncated copy of the internal
    representation of a string when it contained a NUL character.  This can
    occur while simplifying TRANSFER when the physical representation of its
    result is longer than that of SOURCE, and MOLD is of type CHARACTER.
    This lead to an invalid read reported by valgrind.

            PR fortran/127892

    gcc/fortran/ChangeLog:

            * expr.cc (gfc_copy_expr): Ensure that the result representation
            length is the same as that of the source.
            * gfortran.h (gfc_char_to_widechar): Adjust prototype.
            * scanner.cc (gfc_char_to_widechar): Add optional argument for
            the result representation length, instead of deriving it from the
            string argument.

Reply via email to