[flang-commits] [flang] cd55046 - [flang][unittests] Use malloc when memory will be deallcated with free (#84380)

via flang-commits flang-commits at lists.llvm.org
Mon Mar 11 08:29:50 PDT 2024


Author: Krzysztof Parzyszek
Date: 2024-03-11T10:29:46-05:00
New Revision: cd5504637beb1aafeeec08fd339e0e920386eea1

URL: https://github.com/llvm/llvm-project/commit/cd5504637beb1aafeeec08fd339e0e920386eea1
DIFF: https://github.com/llvm/llvm-project/commit/cd5504637beb1aafeeec08fd339e0e920386eea1.diff

LOG: [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.

Added: 
    

Modified: 
    flang/unittests/Runtime/Ragged.cpp

Removed: 
    


################################################################################
diff  --git a/flang/unittests/Runtime/Ragged.cpp b/flang/unittests/Runtime/Ragged.cpp
index 4b261b14789c47..5049bc83405f17 100644
--- a/flang/unittests/Runtime/Ragged.cpp
+++ b/flang/unittests/Runtime/Ragged.cpp
@@ -14,7 +14,7 @@ using namespace Fortran::runtime;
 TEST(Ragged, RaggedArrayAllocateDeallocateTest) {
   struct RaggedArrayHeader header;
   unsigned rank = 2;
-  int64_t *extents = new int64_t[2];
+  int64_t *extents = reinterpret_cast<int64_t *>(malloc(2 * sizeof(int64_t)));
   extents[0] = 10;
   extents[1] = 100;
   RaggedArrayHeader *ret = (RaggedArrayHeader *)_FortranARaggedArrayAllocate(


        


More information about the flang-commits mailing list