From ce423e919f3e2377bb8d371b59f4d3eac64ff2f7 Mon Sep 17 00:00:00 2001 From: Thomas Arp <357770+welcor@users.noreply.github.com> Date: Sun, 19 Apr 2026 01:37:10 +0200 Subject: [PATCH] Fix for code scanning alert no. 74: Potential use after free (#164) Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- .github/workflows/codeql.yml | 2 -- src/dg_triggers.c | 5 +++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 717fe7a..d6a5106 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: C/C++ CI on: push: branches: [ "master" ] - pull_request: + pull_request_target: branches: [ "master" ] jobs: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index a53695a..b2f17cd 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -14,8 +14,6 @@ name: "CodeQL Advanced" on: push: branches: [ "master" ] - pull_request: - branches: [ "master" ] schedule: - cron: '42 10 * * 4' diff --git a/src/dg_triggers.c b/src/dg_triggers.c index 7cea1ad..a569d58 100644 --- a/src/dg_triggers.c +++ b/src/dg_triggers.c @@ -147,7 +147,7 @@ void greet_memory_mtrigger(char_data *actor) { trig_data *t; char_data *ch; - struct script_memory *mem; + struct script_memory *mem, *next_mem; char buf[MAX_INPUT_LENGTH]; int command_performed = 0; @@ -159,7 +159,8 @@ void greet_memory_mtrigger(char_data *actor) AFF_FLAGGED(ch, AFF_CHARM)) continue; /* find memory line with command only */ - for (mem = SCRIPT_MEM(ch); mem && SCRIPT_MEM(ch); mem=mem->next) { + for (mem = SCRIPT_MEM(ch); mem && SCRIPT_MEM(ch); mem = next_mem) { + next_mem = mem->next; if (char_script_id(actor)!=mem->id) continue; if (mem->cmd) { command_interpreter(ch, mem->cmd); /* no script */