]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
items: warn instead of crashing if spawned with no pickup sound set
authorbones_was_here <bones_was_here@xonotic.au>
Sun, 16 Jul 2023 07:30:37 +0000 (17:30 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Sun, 16 Jul 2023 07:30:37 +0000 (17:30 +1000)
Fixes null ptr deref when starting map dfwc2017-6, which was made easy
to trigger by 5606e7035655b105545cc7fbcbffa96e653b4e82

qcsrc/server/items/items.qc

index e06c6f074549e0d6976df8a9cf63ddd1b389fed7..bf9233ecd37126ba1618ff137d11ef1a7320b522 100644 (file)
@@ -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);