Skip to content

Commit 4bf3272

Browse files
committed
[GR-19783] Allocate correct amount of memory for native arrays.
PullRequest: truffleruby/1164
2 parents 8c4783f + 8b53f56 commit 4bf3272

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Bug fixes:
3030
* Fixed the class of `self` and the wrapping `Module` for `Kernel#load(path, wrap=true)` (#1739).
3131
* Fixed missing polyglot type declaration for `RSTRING_PTR` to help with native/managed interop.
3232
* Fixed `Module#to_s` and `Module#inspect` to not return an extra `#<Class:` for singleton classes.
33+
* Arrays backed by native storage now allocate the correct amount of memory (#1828).
3334

3435
Compatibility:
3536

src/main/java/org/truffleruby/core/array/NativeArrayNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static abstract class NativeArrayNewStoreNode extends ArrayOperationNodes
8888

8989
@Specialization
9090
protected NativeArrayStorage newStore(int size) {
91-
Pointer pointer = Pointer.malloc(size);
91+
Pointer pointer = Pointer.malloc(size * Pointer.SIZE);
9292
pointer.enableAutorelease(getContext().getFinalizationService());
9393
return new NativeArrayStorage(pointer, size);
9494
}

0 commit comments

Comments
 (0)