]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: libproc_macro: Copy ffistring data from source
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 16 May 2023 11:25:40 +0000 (13:25 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:37:20 +0000 (18:37 +0100)
Data from source pointer were not copied correctly in the ffistring
constructor.

libgrust/ChangeLog:

* libproc_macro/ffistring.cc (FFIString::make_ffistring):
Add copy from source pointer.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
libgrust/libproc_macro/ffistring.cc

index 1623bc9899e21ca498ac0c28f407682208c8c799..06e4e81dc2453c711d4e0c912c489c97b85948e3 100644 (file)
@@ -41,7 +41,8 @@ FFIString::make_ffistring (const std::string &str)
 FFIString
 FFIString::make_ffistring (const unsigned char *data, std::uint64_t len)
 {
-  const unsigned char *inner = new unsigned char[len];
+  unsigned char *inner = new unsigned char[len];
+  std::memcpy (inner, data, len);
   return {inner, len};
 }