Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bdbf5a4

Browse files
ihsinmegeoffw0
andauthored
Apply suggestions from code review
Co-authored-by: Geoffrey White <[email protected]>
1 parent c8eeb5f commit bdbf5a4

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

cpp/ql/src/experimental/Security/CWE/CWE-570/WrongInDetectingAndHandlingMemoryAllocationErrors.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@ void badFunction(const int *source, std::size_t length) noexcept {
88
void goodFunction(const int *source, std::size_t length) noexcept {
99
try {
1010
int * dest = new int[length];
11-
} catch(std::bad_alloc)
11+
} catch(std::bad_alloc) {
12+
// ...
13+
}
1214
std::memset(dest, 0, length);
1315
// ..
1416
}
1517
// BAD: memory allocation error will not be handled.
1618
void badFunction(const int *source, std::size_t length) noexcept {
1719
try {
1820
int * dest = new (std::nothrow) int[length];
19-
} catch(std::bad_alloc)
21+
} catch(std::bad_alloc) {
22+
// ...
23+
}
2024
std::memset(dest, 0, length);
2125
// ..
2226
}

0 commit comments

Comments
 (0)