Skip to content

Commit ff16199

Browse files
committed
Fix check for number of primitives
1 parent 1c87794 commit ff16199

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

include/gauxc/util/c_basisset.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212
#pragma once
1313

14+
#include <gauxc/exceptions.hpp>
1415
#include <gauxc/shell.h>
1516
#include <gauxc/shell.hpp>
1617
#include <gauxc/basisset.h>
@@ -20,11 +21,15 @@ namespace GauXC::detail {
2021
static inline BasisSet<double>* get_basisset_ptr(C::GauXCBasisSet basis) noexcept {
2122
return static_cast<BasisSet<double>*>(basis.ptr);
2223
}
23-
static inline Shell<double> convert_shell(C::GauXCShell shell, bool normalize) noexcept {
24+
static inline Shell<double> convert_shell(C::GauXCShell shell, bool normalize) {
2425
Shell<double>::prim_array alpha{};
2526
Shell<double>::prim_array coeff{};
2627
Shell<double>::cart_array O{0.0, 0.0, 0.0};
2728

29+
if (shell.nprim > detail::shell_nprim_max) {
30+
GAUXC_GENERIC_EXCEPTION("Number of primitives in shell exceeds maximum allowed");
31+
}
32+
2833
for( int32_t i = 0; i < shell.nprim; ++i ) {
2934
alpha[i] = shell.exponents[i];
3035
coeff[i] = shell.coefficients[i];

src/c_basisset.cxx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ GauXCBasisSet gauxc_basisset_new_from_shells(GauXCStatus* status, GauXCShell* sh
3939
GauXCBasisSet basis{};
4040
basis.hdr = GauXCHeader{GauXC_Type_BasisSet};
4141
basis.ptr = nullptr;
42-
if (nshells > detail::shell_nprim_max) {
43-
status->code = 1;
44-
status->message = detail::strdup("Number of primitives in shell exceeds maximum allowed");
45-
return basis;
46-
}
4742
BasisSet<double>* basis_ptr = nullptr;
4843
try {
4944
basis_ptr = new BasisSet<double>();

0 commit comments

Comments
 (0)