]> git.ipfire.org Git - thirdparty/gcc.git/commit
input: give file_cache_slot its own copy of the file path [PR118919]
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 19 Feb 2025 14:46:43 +0000 (09:46 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 19 Feb 2025 14:46:43 +0000 (09:46 -0500)
commitee6619b1246b38cfb36f6efd931a6f475a9033c7
tree3488f6d042e89076f0488220af7fb7fe6eaf84a0
parent58b90139e093aeb5494627d92257a97aebb4a6d9
input: give file_cache_slot its own copy of the file path [PR118919]

input.cc's file_cache was borrowing copies of the file name.
This could lead to use-after-free when writing out sarif output
from Fortran, which frees its filenames before the sarif output
is fully written out.

Fix by taking a copy in file_cache_slot.

gcc/ChangeLog:
PR other/118919
* input.cc (file_cache_slot::m_file_path): Make non-const.
(file_cache_slot::evict): Free m_file_path.
(file_cache_slot::create): Store a copy of file_path if non-null.
(file_cache_slot::~file_cache_slot): Free m_file_path.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/input.cc