Potential fix for code scanning alert no. 73: Potential use after free (#168)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
Thomas Arp
2026-04-21 23:15:35 +02:00
committed by GitHub
parent a465860553
commit d4089c58e8

View File

@@ -246,7 +246,8 @@ void entry_memory_mtrigger(char_data *ch)
for (actor = world[IN_ROOM(ch)].people; actor && SCRIPT_MEM(ch); for (actor = world[IN_ROOM(ch)].people; actor && SCRIPT_MEM(ch);
actor = actor->next_in_room) { actor = actor->next_in_room) {
if (actor!=ch && SCRIPT_MEM(ch)) { if (actor!=ch && SCRIPT_MEM(ch)) {
for (mem = SCRIPT_MEM(ch); mem && SCRIPT_MEM(ch); mem = mem->next) { for (mem = SCRIPT_MEM(ch); mem && SCRIPT_MEM(ch); ) {
struct script_memory *next_mem = mem->next;
if (char_script_id(actor)==mem->id) { if (char_script_id(actor)==mem->id) {
struct script_memory *prev; struct script_memory *prev;
if (mem->cmd) command_interpreter(ch, mem->cmd); if (mem->cmd) command_interpreter(ch, mem->cmd);
@@ -271,6 +272,7 @@ void entry_memory_mtrigger(char_data *ch)
if (mem->cmd) free(mem->cmd); if (mem->cmd) free(mem->cmd);
free(mem); free(mem);
} }
mem = next_mem;
} /* for (mem =..... */ } /* for (mem =..... */
} }
} }