https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127892
--- Comment #14 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-16 branch has been updated by Harald Anlauf <[email protected]>: https://gcc.gnu.org/g:79435875ebad22469c79ded9ff0089e82c20f0b1 commit r16-9945-g79435875ebad22469c79ded9ff0089e82c20f0b1 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)
