https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127892
--- Comment #16 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-15 branch has been updated by Harald Anlauf <[email protected]>: https://gcc.gnu.org/g:c5faab61fc993e2017844cd4ad7b84acc0cb6e40 commit r15-11728-gc5faab61fc993e2017844cd4ad7b84acc0cb6e40 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. (cherry picked from commit 7099a54b01a0cd04247fe88e3545916ab5ee0d22)
