Skip to content

Commit cd55046

Browse files
authored
[flang][unittests] Use malloc when memory will be deallcated with free (#84380)
Runtime unit tests used `new[]` to allocate memory, which then was released using `free`. This was detected by address sanitizer.
1 parent 9b1c496 commit cd55046

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

flang/unittests/Runtime/Ragged.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ using namespace Fortran::runtime;
1414
TEST(Ragged, RaggedArrayAllocateDeallocateTest) {
1515
struct RaggedArrayHeader header;
1616
unsigned rank = 2;
17-
int64_t *extents = new int64_t[2];
17+
int64_t *extents = reinterpret_cast<int64_t *>(malloc(2 * sizeof(int64_t)));
1818
extents[0] = 10;
1919
extents[1] = 100;
2020
RaggedArrayHeader *ret = (RaggedArrayHeader *)_FortranARaggedArrayAllocate(

0 commit comments

Comments
 (0)