Destroy created file via reference release if necessary.
This commit is contained in:
@@ -41,13 +41,14 @@ DwarfManager::LoadFile(const char* fileName, DwarfFile*& _file)
|
|||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
BReference<DwarfFile> fileReference(file, true);
|
||||||
status_t error = file->Load(fileName);
|
status_t error = file->Load(fileName);
|
||||||
if (error != B_OK) {
|
if (error != B_OK) {
|
||||||
delete file;
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
fFiles.Add(file);
|
fFiles.Add(file);
|
||||||
|
fileReference.Detach();
|
||||||
// we keep the initial reference for ourselves
|
// we keep the initial reference for ourselves
|
||||||
|
|
||||||
file->AcquireReference();
|
file->AcquireReference();
|
||||||
|
|||||||
Reference in New Issue
Block a user