[flang-commits] [flang] [flang][unittests] Use malloc when memory will be deallcated with free (PR #84380)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Thu Mar 7 13:29:55 PST 2024
https://github.com/kparzysz created https://github.com/llvm/llvm-project/pull/84380
Runtime unit tests used `new` to allocate memory, which then was released using `free`.
This was detected by address sanitizer.
>From 374c507296ef8bb1eade126bc809b51c93746e16 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Thu, 7 Mar 2024 15:26:53 -0600
Subject: [PATCH] [flang][unittests] Use malloc when memory will be deallcated
with free
Runtime unit tests used `new` to allocate memory, which then was released
using `free`.
This was detected by address sanitizer.
---
flang/unittests/Runtime/Ragged.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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