8294717: (bf) DirectByteBuffer constructor will leak if allocating Deallocator or Cleaner fails with OOME
Reviewed-by: alanb
This commit is contained in:
parent
c1166a304d
commit
4cbac40de9
@ -141,7 +141,14 @@ class Direct$Type$Buffer$RW$$BO$
|
||||
} else {
|
||||
address = base;
|
||||
}
|
||||
cleaner = Cleaner.create(this, new Deallocator(base, size, cap));
|
||||
try {
|
||||
cleaner = Cleaner.create(this, new Deallocator(base, size, cap));
|
||||
} catch (Throwable t) {
|
||||
// Prevent leak if the Deallocator or Cleaner fail for any reason
|
||||
UNSAFE.freeMemory(base);
|
||||
Bits.unreserveMemory(size, cap);
|
||||
throw t;
|
||||
}
|
||||
att = null;
|
||||
#else[rw]
|
||||
super(cap);
|
||||
|
Loading…
x
Reference in New Issue
Block a user