Skip to content

Commit

Permalink
Merge pull request #991 from google/fix-buffer-overflow
Browse files Browse the repository at this point in the history
Fix allocation sizes.
  • Loading branch information
adetaylor authored Apr 2, 2022
2 parents 64f3cea + e151717 commit bdfd45e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion engine/src/conversion/codegen_cpp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ impl<'a> CppCodeGenerator<'a> {
CppFunctionBody::AllocUninitialized(ty) => {
let namespaced_ty = self.namespaced_name(ty);
(
format!("new_appropriately<{}>(1);", namespaced_ty,),
format!("new_appropriately<{}>();", namespaced_ty,),
"".to_string(),
true,
)
Expand Down
4 changes: 2 additions & 2 deletions engine/src/conversion/codegen_cpp/new_and_delete_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ pub(super) static NEW_AND_DELETE_PRELUDE: &str = indoc! {"
template <typename T> void *new_imp(size_t count, long) {
return ::operator new(count);
}
template <typename T> T *new_appropriately(size_t count) {
template <typename T> T *new_appropriately() {
// 0 is a better match for the first 'delete_imp' so will match
// preferentially.
return static_cast<T *>(new_imp<T>(count, 0));
return static_cast<T *>(new_imp<T>(sizeof(T), 0));
}
#endif // AUTOCXX_NEW_AND_DELETE_PRELUDE
"};

0 comments on commit bdfd45e

Please sign in to comment.