Fix more memory errors

This commit is contained in:
MysterD 2023-05-18 01:57:36 -07:00
parent 87f076cd26
commit ddd2f19ca1
5 changed files with 12 additions and 49 deletions

View file

@ -1,39 +0,0 @@
==899764== exp-sgcheck, a stack and global array overrun detector
==899764== NOTE: This is an Experimental-Class Valgrind Tool
==899764== Copyright (C) 2003-2017, and GNU GPL'd, by OpenWorks Ltd et al.
==899764== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==899764== Command: ./build/us_pc/sm64.us.f3dex2e
==899764== Parent PID: 10640
==899764==
--899764-- warning: evaluate_Dwarf3_Expr: unhandled DW_OP_ 0x93
--899764-- warning: evaluate_Dwarf3_Expr: unhandled DW_OP_ 0x93
--899764-- warning: evaluate_Dwarf3_Expr: unhandled DW_OP_ 0x93
--899764-- warning: evaluate_Dwarf3_Expr: unhandled DW_OP_ 0x93
--899764-- warning: evaluate_Dwarf3_Expr: unhandled DW_OP_ 0x93
--899764-- warning: evaluate_Dwarf3_Expr: unhandled DW_OP_ 0x93
--899764-- warning: evaluate_Dwarf3_Expr: unhandled DW_OP_ 0x93
--899764-- warning: evaluate_Dwarf3_Expr: unhandled DW_OP_ 0x93
parse DIE(readdwarf3.c:3123): confused by:
<0><19f35>: Abbrev Number: 1 (DW_TAG_compile_unit)
DW_AT_producer : (indirect string, offset: 0x6663): clang LLVM (rustc version 1.39.0-nightly (6ef275e6c 2019-09-24))
DW_AT_language : 28
DW_AT_name : (indirect string, offset: 0x66a4): src/libstd/lib.rs
DW_AT_stmt_list : 46860
DW_AT_comp_dir : (indirect string, offset: 0x66b6): /rustc/6ef275e6c3cb1384ec78128eceeb4963ff788dca/
DW_AT_??? : 1
DW_AT_low_pc : 0x0
DW_AT_ranges : 240976
parse_type_DIE:
--899764-- WARNING: Serious error when reading debug info
--899764-- When reading debug info from /home/djoslin/sm64ex-coop/lib/discordsdk/libdiscord_game_sdk.so:
--899764-- confused by the above DIE
==899764== Warning: noted but unhandled ioctl 0x6444 with no size/direction hints.
==899764== This could cause spurious value errors to appear.
==899764== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==899764== Warning: unimplemented fcntl command: 1033
==899764== Warning: unimplemented fcntl command: 1033
==899764== Warning: bogus DWARF3 info: overlapping stack blocks
==899764== Warning: bogus DWARF3 info: overlapping stack blocks
==899764== Warning: bogus DWARF3 info: overlapping stack blocks
==899764== Further instances of this message will not be shown

View file

@ -377,6 +377,11 @@ static void level_reset_globals(void) {
gAreas[i].unk04 = NULL; gAreas[i].unk04 = NULL;
} }
// clear mariostate spawninfo pointers
for (int i = 0; i < MAX_PLAYERS; i++) {
gMarioStates[i].spawnInfo = NULL;
}
// free models stored in dynos // free models stored in dynos
dynos_model_clear_pool(MODEL_POOL_LEVEL); dynos_model_clear_pool(MODEL_POOL_LEVEL);
} }

View file

@ -38,7 +38,7 @@ void bhv_chain_chomp_chain_part_update(void) {
obj_mark_for_deletion(o); obj_mark_for_deletion(o);
network_send_object(o); network_send_object(o);
} else if (o->oBehParams2ndByte != CHAIN_CHOMP_CHAIN_PART_BP_PIVOT) { } else if (o->oBehParams2ndByte != CHAIN_CHOMP_CHAIN_PART_BP_PIVOT) {
struct ChainSegment *segment = (o->oBehParams2ndByte <= 4 && o->parentObj) struct ChainSegment *segment = (o->oBehParams2ndByte >= 0 && o->oBehParams2ndByte <= 4 && o->parentObj)
? &o->parentObj->oChainChompSegments[o->oBehParams2ndByte] ? &o->parentObj->oChainChompSegments[o->oBehParams2ndByte]
: NULL; : NULL;
@ -454,13 +454,6 @@ static void chain_chomp_act_unload_chain(void) {
o->oAction = CHAIN_CHOMP_ACT_UNINITIALIZED; o->oAction = CHAIN_CHOMP_ACT_UNINITIALIZED;
if (o->oChainChompReleaseStatus != CHAIN_CHOMP_NOT_RELEASED) { if (o->oChainChompReleaseStatus != CHAIN_CHOMP_NOT_RELEASED) {
if (o->oChainChompSegments) {
for (u8 i = 0; i < 5; i++) {
struct Object* segment = (struct Object*)&o->oChainChompSegments[i];
if (!segment) { continue; }
obj_mark_for_deletion(segment);
}
}
obj_mark_for_deletion(o); obj_mark_for_deletion(o);
obj_mark_for_deletion(o->parentObj); obj_mark_for_deletion(o->parentObj);
} }

View file

@ -321,6 +321,9 @@ struct Object *allocate_object(struct ObjectNode *objList) {
obj->header.gfx.pos[1] = -10000.0f; obj->header.gfx.pos[1] = -10000.0f;
obj->header.gfx.pos[2] = -10000.0f; obj->header.gfx.pos[2] = -10000.0f;
obj->header.gfx.throwMatrix = NULL; obj->header.gfx.throwMatrix = NULL;
obj->header.gfx.angle[0] = 0;
obj->header.gfx.angle[1] = 0;
obj->header.gfx.angle[2] = 0;
obj->coopFlags = 0; obj->coopFlags = 0;
obj->hookRender = 0; obj->hookRender = 0;

View file

@ -1135,10 +1135,11 @@ int smlua_hook_behavior(lua_State* L) {
struct LuaHookedBehavior* hooked = &sHookedBehaviors[sHookedBehaviorsCount]; struct LuaHookedBehavior* hooked = &sHookedBehaviors[sHookedBehaviorsCount];
u16 customBehaviorId = (sHookedBehaviorsCount & 0xFFFF) | LUA_BEHAVIOR_FLAG; u16 customBehaviorId = (sHookedBehaviorsCount & 0xFFFF) | LUA_BEHAVIOR_FLAG;
hooked->behavior = calloc(3, sizeof(BehaviorScript)); hooked->behavior = calloc(4, sizeof(BehaviorScript));
hooked->behavior[0] = (BehaviorScript)BC_BB(0x00, objectList); // This is BEGIN(objectList) hooked->behavior[0] = (BehaviorScript)BC_BB(0x00, objectList); // This is BEGIN(objectList)
hooked->behavior[1] = (BehaviorScript)BC_B0H(0x39, customBehaviorId); // This is ID(customBehaviorId) hooked->behavior[1] = (BehaviorScript)BC_B0H(0x39, customBehaviorId); // This is ID(customBehaviorId)
hooked->behavior[2] = 0; hooked->behavior[2] = (BehaviorScript)BC_B(0x0A); // This is BREAK()
hooked->behavior[3] = (BehaviorScript)BC_B(0x0A); // This is BREAK()
hooked->behaviorId = customBehaviorId; hooked->behaviorId = customBehaviorId;
hooked->overrideId = noOverrideId ? customBehaviorId : overrideBehaviorId; hooked->overrideId = noOverrideId ? customBehaviorId : overrideBehaviorId;
hooked->originalId = customBehaviorId; // For LUA behaviors. The only behavior id they have IS their custom one. hooked->originalId = customBehaviorId; // For LUA behaviors. The only behavior id they have IS their custom one.