Protect use of alloca.

This commit is contained in:
Antonio Sanchez 2024-03-22 15:05:34 -07:00 committed by Charles Schlosser
parent b86641a4c2
commit a39ade4ccf

View File

@ -301,9 +301,13 @@ struct trmv_selector<Mode, RowMajor> {
} else { } else {
// Allocate either with alloca or malloc. // Allocate either with alloca or malloc.
Eigen::internal::check_size_for_overflow<RhsScalar>(actualRhs.size()); Eigen::internal::check_size_for_overflow<RhsScalar>(actualRhs.size());
#ifdef EIGEN_ALLOCA
buffer = static_cast<RhsScalar*>((sizeof(RhsScalar) * actualRhs.size() <= EIGEN_STACK_ALLOCATION_LIMIT) buffer = static_cast<RhsScalar*>((sizeof(RhsScalar) * actualRhs.size() <= EIGEN_STACK_ALLOCATION_LIMIT)
? EIGEN_ALIGNED_ALLOCA(sizeof(RhsScalar) * actualRhs.size()) ? EIGEN_ALIGNED_ALLOCA(sizeof(RhsScalar) * actualRhs.size())
: Eigen::internal::aligned_malloc(sizeof(RhsScalar) * actualRhs.size())); : Eigen::internal::aligned_malloc(sizeof(RhsScalar) * actualRhs.size()));
#else
buffer = static_cast<RhsScalar*>(Eigen::internal::aligned_malloc(sizeof(RhsScalar) * actualRhs.size()));
#endif
} }
#ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
Index size = actualRhs.size(); Index size = actualRhs.size();