Skip to content

Commit 5a73180

Browse files
Abduqodiri Qurbonzodaqurbonzoda
authored andcommitted
Fix memory leak in map iterator
1 parent a5f78bc commit 5a73180

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

core/commonMain/src/implementations/immutableMap/PersistentHashMapContentIterators.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ internal open class MapEntry<out K, out V>(override val key: K, override val val
9898
}
9999

100100

101-
internal abstract class PersistentHashMapBaseIterator<K, V, T>(node: TrieNode<K, V>,
102-
protected val path: Array<TrieNodeBaseIterator<K, V, T>>) : Iterator<T> {
101+
internal abstract class PersistentHashMapBaseIterator<K, V, T>(
102+
node: TrieNode<K, V>,
103+
protected val path: Array<TrieNodeBaseIterator<K, V, T>>
104+
) : Iterator<T> {
105+
103106
private var pathLastIndex = 0
104107
@JsName("_hasNext")
105108
private var hasNext = true
@@ -144,6 +147,7 @@ internal abstract class PersistentHashMapBaseIterator<K, V, T>(node: TrieNode<K,
144147
if (i > 0) {
145148
path[i - 1].moveToNextNode()
146149
}
150+
path[i].reset(TrieNode.EMPTY.buffer, 0)
147151
}
148152
hasNext = false
149153
}

0 commit comments

Comments
 (0)