aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-11-17 15:26:43 +0100
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2023-11-21 10:17:09 +0000
commit5f0e77ad4623bc5450808367d902836b7257066b (patch)
treebf5a5d843576facd3030bf0c6efea52ce1770d94
parent1a758c3a9bb3e57a8d168e66f37c63ac024df4d5 (diff)
downloadgcc-5f0e77ad4623bc5450808367d902836b7257066b.zip
gcc-5f0e77ad4623bc5450808367d902836b7257066b.tar.gz
gcc-5f0e77ad4623bc5450808367d902836b7257066b.tar.bz2
fixup: Ensure buffer allocation for bootstrap
Bootstrap was failing because the vector did not allocate the internal buffer and was holding a null pointer. Commit to fixup is b71fd2afa831 gcc/rust/ChangeLog: * expand/rust-proc-macro.cc (generate_proc_macro_decls_symbol): Resize the vector and initialize it with dummy data before changing it. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r--gcc/rust/expand/rust-proc-macro.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/rust/expand/rust-proc-macro.cc b/gcc/rust/expand/rust-proc-macro.cc
index 3865b87..c5bd87a 100644
--- a/gcc/rust/expand/rust-proc-macro.cc
+++ b/gcc/rust/expand/rust-proc-macro.cc
@@ -183,7 +183,8 @@ generate_proc_macro_decls_symbol (std::uint32_t stable_crate_id)
// Size could be hardcoded since we know the input size but I elected to
// calculate it everytime so we won't have any desync between code and data.
int size = std::snprintf (nullptr, 0, PROC_MACRO_DECLS_FMT_ARGS);
- std::vector<char> buf (size + 1);
+ std::vector<char> buf;
+ buf.resize (size + 1, '\0');
std::sprintf (buf.data (), PROC_MACRO_DECLS_FMT_ARGS);
#undef PROC_MACRO_DECLS_FMT_ARGS