Skip to content

Commit

Permalink
Merge pull request #628 from jneira/empty-buffer
Browse files Browse the repository at this point in the history
add null pointer case
  • Loading branch information
rahulmutt committed Jan 30, 2018
2 parents 69df80d + 1ded0b0 commit aefdb1a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rts/src/main/java/eta/runtime/io/MemoryManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public class MemoryManager {
MANAGED_HEAP_BLOCK_SIZE,
MANAGED_HEAP_MINIBLOCK_SIZE);

/* The shared empty buffer */
private final static ByteBuffer emptyBuffer = ByteBuffer.allocate(0);

public static ManagedHeap getHeap() {
return globalManagedHeap;
}
Expand Down Expand Up @@ -102,6 +105,8 @@ private static Block getBlockSlow(long address) {
Throws an exception if the block that corresponds to the address has been freed. */
public static ByteBuffer getBoundedBuffer(long address) {
if (address == 0)
return emptyBuffer;
return getBlock(address).getBoundedBuffer(address);
}

Expand Down

0 comments on commit aefdb1a

Please sign in to comment.