mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-05-26 18:52:08 +00:00
defensive crash fix in smlua_model_util_get_id
Some checks are pending
Some checks are pending
This commit is contained in:
parent
834512a5c5
commit
3bd5dc842f
1 changed files with 12 additions and 0 deletions
|
|
@ -594,6 +594,14 @@ enum ModelExtendedId smlua_model_util_get_id(const char* name) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!sCustomModels) {
|
||||
smlua_model_util_initialize();
|
||||
if (!sCustomModels) {
|
||||
LOG_LUA("Failed to initialize custom models!");
|
||||
return E_MODEL_ERROR_MODEL;
|
||||
}
|
||||
}
|
||||
|
||||
// If we've extended past our current custom model limit. Reallocate so we have more space.
|
||||
if (sCustomModelsCount >= sMaxCustomModelsCount) {
|
||||
if (sMaxCustomModelsCount + CUSTOM_MODEL_CHUNK_SIZE >= 0xFFFF) {
|
||||
|
|
@ -603,6 +611,10 @@ enum ModelExtendedId smlua_model_util_get_id(const char* name) {
|
|||
sMaxCustomModelsCount += CUSTOM_MODEL_CHUNK_SIZE;
|
||||
sCustomModels = (struct ModelUtilsInfo *)realloc(sCustomModels, sMaxCustomModelsCount * sizeof(struct ModelUtilsInfo));
|
||||
}
|
||||
if (!sCustomModels) {
|
||||
LOG_LUA("Failed to allocate custom model: '%s'", name);
|
||||
return E_MODEL_ERROR_MODEL;
|
||||
}
|
||||
|
||||
// Allocate custom model
|
||||
u16 customIndex = sCustomModelsCount++;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue