This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 0/3] More cleanup elimination / gdb::unique_ptr


>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> I'm not sure whether patch #2 is just delayed, or whether it was
Pedro> too big for the list (172K on disk).

I found a buglet in patch #2.  Namely, in rust-lang.c there are some
assignments using concat that aren't converted to properly use
std::string.  This results in a memory leak.

In particular look at rust_get_disr_info - I've appended a hunk from a
patch of mine (untested), but note mine deletes the do_cleanups, which
you don't want to do.

Tom

diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 5b81283..148e980 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -172,17 +171,15 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr,
       if (value == 0)
 	{
 	  ret.field_no = RUST_ENCODED_ENUM_HIDDEN;
-	  ret.name = concat (TYPE_NAME (type), "::", token, (char *) NULL);
+	  ret.name = std::string (TYPE_NAME (type)) + "::" + token;
 	}
       else
 	{
 	  ret.field_no = RUST_ENCODED_ENUM_REAL;
-	  ret.name = concat (TYPE_NAME (type), "::",
-			     rust_last_path_segment (TYPE_NAME (TYPE_FIELD_TYPE (type, 0))),
-			     (char *) NULL);
+	  ret.name = (std::string (TYPE_NAME (type)) + "::"
+		      + rust_last_path_segment (TYPE_NAME (TYPE_FIELD_TYPE (type, 0))));
 	}
 
-      do_cleanups (cleanup);
       return ret;
     }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]