Skip to content

Commit

Permalink
fixup: Ensure buffer allocation for bootstrap
Browse files Browse the repository at this point in the history
Bootstrap was failing because the vector did not allocate the internal
buffer and was holding a null pointer.

Commit to fixup is b71fd2a

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 <[email protected]>
  • Loading branch information
P-E-P committed Nov 21, 2023
1 parent 1a758c3 commit 5f0e77a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gcc/rust/expand/rust-proc-macro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 5f0e77a

Please sign in to comment.