block_cache::NewBlock(): Allocate cached_block::current_data only when the
block was freshly allocated. A block returned by _GetUnusedBlock() already has current_data and we would leak it before. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35918 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
59a4ec37b5
commit
c561bf792b
14
src/system/kernel/cache/block_cache.cpp
vendored
14
src/system/kernel/cache/block_cache.cpp
vendored
@ -1412,7 +1412,13 @@ block_cache::NewBlock(off_t blockNumber)
|
||||
}
|
||||
if (block == NULL) {
|
||||
block = (cached_block*)object_cache_alloc(sBlockCache, 0);
|
||||
if (block == NULL) {
|
||||
if (block != NULL) {
|
||||
block->current_data = Allocate();
|
||||
if (block->current_data == NULL) {
|
||||
object_cache_free(sBlockCache, block, 0);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
TB(Error(this, blockNumber, "allocation failed"));
|
||||
dprintf("block allocation failed, unused list is %sempty.\n",
|
||||
unused_blocks.IsEmpty() ? "" : "not ");
|
||||
@ -1427,12 +1433,6 @@ block_cache::NewBlock(off_t blockNumber)
|
||||
}
|
||||
}
|
||||
|
||||
block->current_data = Allocate();
|
||||
if (block->current_data == NULL) {
|
||||
object_cache_free(sBlockCache, block, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
block->block_number = blockNumber;
|
||||
block->ref_count = 0;
|
||||
block->last_accessed = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user