projects
/
platform
/
upstream
/
llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7c7ffa7
)
[flang][runtime] Fixed memory leak in Assign().
author
Slava Zakharin
<szakharin@nvidia.com>
Mon, 15 May 2023 16:52:14 +0000
(09:52 -0700)
committer
Slava Zakharin
<szakharin@nvidia.com>
Mon, 15 May 2023 17:48:46 +0000
(10:48 -0700)
The temporary descriptor must be either Pointer or Allocatable,
otherwise its memory will not be freed.
Reviewed By: klausler
Differential Revision: https://reviews.llvm.org/D150534
flang/runtime/assign.cpp
patch
|
blob
|
history
diff --git
a/flang/runtime/assign.cpp
b/flang/runtime/assign.cpp
index
9e10e2f
..
f75fe94
100644
(file)
--- a/
flang/runtime/assign.cpp
+++ b/
flang/runtime/assign.cpp
@@
-294,6
+294,10
@@
static void Assign(
StaticDescriptor<maxRank, true, 16> staticDesc;
Descriptor &newFrom{staticDesc.descriptor()};
std::memcpy(&newFrom, &from, descBytes);
+ // Pretend the temporary descriptor is for an ALLOCATABLE
+ // entity, otherwise, the Deallocate() below will not
+ // free the descriptor memory.
+ newFrom.raw().attribute = CFI_attribute_allocatable;
auto stat{ReturnError(terminator, newFrom.Allocate())};
if (stat == StatOk) {
char *toAt{newFrom.OffsetElement()};