mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +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 {
|
} else {
|
||||||
address = base;
|
address = base;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
cleaner = Cleaner.create(this, new Deallocator(base, size, cap));
|
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;
|
att = null;
|
||||||
#else[rw]
|
#else[rw]
|
||||||
super(cap);
|
super(cap);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue