Skip to content

Commit e015c59

Browse files
committed
fix: remove memory leak
1 parent 2dadbf7 commit e015c59

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

math/iterative_factorial.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace math {
4646
*/
4747
uint64_t iterativeFactorial(uint8_t n) {
4848
if (n > 20) {
49-
throw new std::invalid_argument("Maximum n value is 20");
49+
throw std::invalid_argument("Maximum n value is 20");
5050
}
5151

5252
// 1 because it is the identity number of multiplication.
@@ -103,9 +103,9 @@ static void test() {
103103
"Expected output: Exception thrown \n";
104104
try {
105105
math::iterativeFactorial(21);
106-
} catch (std::invalid_argument* e) {
107-
std::cout << "Exception thrown successfully \nContent: " << e->what()
108-
<< "\n";
106+
} catch (const std::invalid_argument& e) {
107+
std::cout << "Exception thrown successfully \nContent: " << e.what()
108+
<< '\n';
109109
}
110110

111111
std::cout << "All tests have passed successfully.\n";

0 commit comments

Comments
 (0)