From 9375a0a0df0b5753b14de78cbde928547fb45ad3 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Sun, 16 Jul 2023 17:30:37 +1000 Subject: [PATCH] items: warn instead of crashing if spawned with no pickup sound set Fixes null ptr deref when starting map dfwc2017-6, which was made easy to trigger by 5606e7035655b105545cc7fbcbffa96e653b4e82 --- qcsrc/server/items/items.qc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index e06c6f074..bf9233ecd 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -976,9 +976,13 @@ void StartItem(entity this, entity def) startitem_failed = false; this.item_model_ent = def.m_model; - this.item_pickupsound_ent = def.m_sound; - if (!this.item_pickupsound) + + if (!this.item_pickupsound_ent) + this.item_pickupsound_ent = def.m_sound; + if (!this.item_pickupsound && this.item_pickupsound_ent) this.item_pickupsound = Sound_fixpath(this.item_pickupsound_ent); + if (this.item_pickupsound == "") + LOG_WARNF("No pickup sound set for a %s", this.classname); if(def.m_iteminit) def.m_iteminit(def, this); -- 2.39.2