From: bones_was_here Date: Sun, 16 Jul 2023 07:30:37 +0000 (+1000) Subject: items: warn instead of crashing if spawned with no pickup sound set X-Git-Url: http://de.git.xonotic.org/?a=commitdiff_plain;h=9375a0a0df0b5753b14de78cbde928547fb45ad3;p=xonotic%2Fxonotic-data.pk3dir.git 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 --- 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);