mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
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
1 changed files with 8 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue