Skip to content

Commit 9b64ccd

Browse files
committed
Fix using wrong size when deallocating object native sequence storage
1 parent b8fa964 commit 9b64ccd

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3119,7 +3119,8 @@ private static NativeSequenceStorage reallocNativeSequenceStorage(NativeSequence
31193119
if (lib.isNull(ptr)) {
31203120
throw raiseNode.get(inliningTarget).raise(MemoryError);
31213121
}
3122-
s.setPtrAndSize(ptr, newCapacity);
3122+
s.setPtr(ptr);
3123+
s.setCapacity(newCapacity);
31233124
}
31243125
return s;
31253126
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/NativeSequenceStorage.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,15 @@ public Object getPtr() {
8686
return ptr;
8787
}
8888

89-
public void setPtrAndSize(Object ptr, int size) {
89+
public void setPtr(Object ptr) {
9090
if (reference != null) {
9191
reference.setPtr(ptr);
92-
reference.setSize(size);
9392
}
9493
this.ptr = ptr;
95-
this.capacity = size;
94+
}
95+
96+
public void setCapacity(int capacity) {
97+
this.capacity = capacity;
9698
}
9799

98100
public void setReference(NativeStorageReference reference) {
@@ -108,6 +110,9 @@ public ListStorageType getElementType() {
108110
public void setNewLength(int length) {
109111
assert length <= capacity;
110112
this.length = length;
113+
if (reference != null) {
114+
reference.setSize(length);
115+
}
111116
}
112117

113118
@Override

0 commit comments

Comments
 (0)