public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6640] middle-end/101292 - invalid memory access with warning control
@ 2022-01-17 15:17 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-01-17 15:17 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:1374d4b963a6ac2e0ec1645c09e5162e68b009d6
commit r12-6640-g1374d4b963a6ac2e0ec1645c09e5162e68b009d6
Author: Richard Biener <rguenther@suse.de>
Date: Mon Jan 17 15:22:11 2022 +0100
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.
Diff:
---
gcc/diagnostic-spec.c | 5 ++++-
gcc/warning-control.cc | 3 ++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/gcc/diagnostic-spec.c b/gcc/diagnostic-spec.c
index a8af229d677..4341ccfaae9 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);
}
diff --git a/gcc/warning-control.cc b/gcc/warning-control.cc
index f9808bf4392..fa39ecab421 100644
--- a/gcc/warning-control.cc
+++ b/gcc/warning-control.cc
@@ -206,7 +206,8 @@ void copy_warning (ToType to, FromType from)
gcc_assert (supp);
gcc_checking_assert (nowarn_map);
- nowarn_map->put (to_loc, *from_spec);
+ nowarn_spec_t tem = *from_spec;
+ nowarn_map->put (to_loc, tem);
}
else
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-17 15:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-17 15:17 [gcc r12-6640] middle-end/101292 - invalid memory access with warning control Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).