Skip to content

Commit

Permalink
Memory.grow returns previous pages, not current
Browse files Browse the repository at this point in the history
  • Loading branch information
bhelx committed Oct 13, 2023
1 parent 2811dd3 commit 8ac8043
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions runtime/src/main/java/com/dylibso/chicory/runtime/Memory.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public int getSize() {
}

public int grow(int size) {
int numPages = this.nPages + size;
var prevPages = nPages;
var numPages = nPages + size;
// TODO if max is null then we just let it grow as much as it wants?
if (limits.getMaximum() != null && numPages >= limits.getMaximum())
throw new RuntimeException("Program exceeded max pages: " + limits.getMaximum());
Expand All @@ -52,7 +53,7 @@ public int grow(int size) {
result.position(position);
buffer = result;
nPages = numPages;
return nPages;
return prevPages;
}

public int getInitialSize() {
Expand Down

0 comments on commit 8ac8043

Please sign in to comment.