diff options
author | Richard Biener <rguenther@suse.de> | 2022-01-17 15:22:11 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2022-01-17 16:16:49 +0100 |
commit | 1374d4b963a6ac2e0ec1645c09e5162e68b009d6 (patch) | |
tree | c2742e65d590c4e12476f9b29a9d53aa0be1ba41 /gcc/diagnostic-spec.c | |
parent | deb9f18f67788c36f4652bca101d93faf07ecf39 (diff) | |
download | gcc-1374d4b963a6ac2e0ec1645c09e5162e68b009d6.zip gcc-1374d4b963a6ac2e0ec1645c09e5162e68b009d6.tar.gz gcc-1374d4b963a6ac2e0ec1645c09e5162e68b009d6.tar.bz2 |
middle-end/101292 - invalid memory access with warning control
The warning control falls into the C++ trap of using a reference
to old hashtable contents for a put operation which can end up
re-allocating that before reading from the old freed referenced to
source. Fixed by introducing a temporary.
2022-01-17 Richard Biener <rguenther@suse.de>
PR middle-end/101292
* diagnostic-spec.c (copy_warning): Make sure to not
reference old hashtable content on possible resize.
* warning-control.cc (copy_warning): Likewise.
Diffstat (limited to 'gcc/diagnostic-spec.c')
-rw-r--r-- | gcc/diagnostic-spec.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/diagnostic-spec.c b/gcc/diagnostic-spec.c index a8af229..4341ccf 100644 --- a/gcc/diagnostic-spec.c +++ b/gcc/diagnostic-spec.c @@ -195,7 +195,10 @@ copy_warning (location_t to, location_t from) else { if (from_spec) - nowarn_map->put (to, *from_spec); + { + nowarn_spec_t tem = *from_spec; + nowarn_map->put (to, tem); + } else nowarn_map->remove (to); } |