Remove modules from the object table if they fail to load.

This commit is contained in:
Dr. Chat 2015-12-26 16:17:18 -06:00 committed by Ben Vanik
parent 3e6c70defa
commit 2855036f72
1 changed files with 5 additions and 0 deletions

View File

@ -303,13 +303,18 @@ object_ref<UserModule> KernelState::LoadUserModule(const char* raw_name,
}
}
global_lock.unlock();
// Module wasn't loaded, so load it.
module = object_ref<UserModule>(new UserModule(this, path.c_str()));
X_STATUS status = module->LoadFromFile(path);
if (XFAILED(status)) {
object_table()->RemoveHandle(module->handle());
return nullptr;
}
global_lock.lock();
// Retain when putting into the listing.
module->Retain();
user_modules_.push_back(module);