]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: clear internalvar on destruction
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 10 Mar 2025 15:10:47 +0000 (11:10 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Wed, 19 Mar 2025 19:15:28 +0000 (15:15 -0400)
The data associated to an internalvar is destroyed when changing the
kind of the internalvar, but not when it is destroyed.  Fix that by
calling clear_internalvar in ~internalvar.

A move constructor becomes needed to avoid freeing things multiple times
when internalvars are moved (and if we forget it, clang helpfully gives
us a -Wdeprecated-copy-with-user-provided-dtor warning).

Change-Id: I427718569208fd955ea25e94d341dde356725033
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
gdb/value.c

index 18c9f749467442f9d72110922959d642a7576d16..8b8b5c8f4de14f05f2a00704b73372b777561fef 100644 (file)
@@ -1872,6 +1872,19 @@ struct internalvar
     : name (std::move (name))
   {}
 
+  internalvar (internalvar &&other)
+    : name (std::move(other.name)),
+      kind (other.kind),
+      u (other.u)
+  {
+    other.kind = INTERNALVAR_VOID;
+  }
+
+  ~internalvar ()
+  {
+    clear_internalvar (this);
+  }
+
   std::string name;
 
   /* We support various different kinds of content of an internal variable.