diff --git a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp index 48bf78dd23..257fb3d872 100644 --- a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp +++ b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp @@ -517,7 +517,8 @@ BlockAllocator::BlockAllocator(Volume* volume) : fVolume(volume), fGroups(NULL), - fCheckBitmap(NULL) + fCheckBitmap(NULL), + fCheckCookie(NULL) { mutex_init(&fLock, "bfs allocator"); } @@ -538,7 +539,7 @@ BlockAllocator::Initialize(bool full) fNumBlocks = (fVolume->NumBlocks() + fVolume->BlockSize() * 8 - 1) / (fVolume->BlockSize() * 8); - fGroups = new AllocationGroup[fNumGroups]; + fGroups = new(std::nothrow) AllocationGroup[fNumGroups]; if (fGroups == NULL) return B_NO_MEMORY; @@ -1215,7 +1216,7 @@ BlockAllocator::StartChecking(const check_control* control) return B_NO_MEMORY; } - fCheckCookie = new check_cookie(); + fCheckCookie = new(std::nothrow) check_cookie(); if (fCheckCookie == NULL) { free(fCheckBitmap); fCheckBitmap = NULL; @@ -1432,7 +1433,7 @@ BlockAllocator::CheckNextNode(check_control* control) fCheckCookie->parent = inode; fCheckCookie->parent_mode = inode->Mode(); - fCheckCookie->iterator = new TreeIterator(tree); + fCheckCookie->iterator = new(std::nothrow) TreeIterator(tree); if (fCheckCookie->iterator == NULL) RETURN_ERROR(B_NO_MEMORY); diff --git a/src/add-ons/kernel/file_systems/bfs/Volume.cpp b/src/add-ons/kernel/file_systems/bfs/Volume.cpp index 9555d6219f..a7166947f3 100644 --- a/src/add-ons/kernel/file_systems/bfs/Volume.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Volume.cpp @@ -356,7 +356,7 @@ Volume::Mount(const char* deviceName, uint32 flags) if ((fBlockCache = opener.InitCache(NumBlocks(), fBlockSize)) == NULL) return B_ERROR; - fJournal = new Journal(this); + fJournal = new(std::nothrow) Journal(this); if (fJournal == NULL) return B_NO_MEMORY; @@ -384,15 +384,17 @@ Volume::Mount(const char* deviceName, uint32 flags) return status; } - fRootNode = new Inode(this, ToVnode(Root())); + fRootNode = new(std::nothrow) Inode(this, ToVnode(Root())); if (fRootNode != NULL && fRootNode->InitCheck() == B_OK) { status = publish_vnode(fVolume, ToVnode(Root()), (void*)fRootNode, &gBFSVnodeOps, fRootNode->Mode(), 0); if (status == B_OK) { // try to get indices root dir - if (!Indices().IsZero()) - fIndicesNode = new Inode(this, ToVnode(Indices())); + if (!Indices().IsZero()) { + fIndicesNode = new(std::nothrow) Inode(this, + ToVnode(Indices())); + } if (fIndicesNode == NULL || fIndicesNode->InitCheck() < B_OK @@ -690,7 +692,7 @@ Volume::Initialize(int fd, const char* name, uint32 blockSize, if ((fBlockCache = opener.InitCache(NumBlocks(), fBlockSize)) == NULL) return B_ERROR; - fJournal = new Journal(this); + fJournal = new(std::nothrow) Journal(this); if (fJournal == NULL || fJournal->InitCheck() < B_OK) RETURN_ERROR(B_ERROR);