]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/charset.c
[gdb/symtab] Fix data race in ~charset_vector
[thirdparty/binutils-gdb.git] / gdb / charset.c
index 74f742e0aa70d30765f5ea97136b79f00454365b..a6261fc505c4ea1d63c045ab3673e4634754fa2f 100644 (file)
@@ -694,7 +694,13 @@ struct charset_vector
 {
   ~charset_vector ()
   {
-    clear ();
+    /* Note that we do not call charset_vector::clear, which would also xfree
+       the elements.  This destructor is only called after exit, at which point
+       those will be freed anyway on process exit, so not freeing them now is
+       not classified as a memory leak.  OTOH, freeing them now might be
+       classified as a data race, because some worker thread might still be
+       accessing them.  */
+    charsets.clear ();
   }
 
   void clear ()