Using local uninitialized (?) class arrays causes crash

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Using local uninitialized (?) class arrays causes crash

Re: Using local uninitialized (?) class arrays causes crash

by _mental_ » Sun Jun 07, 2020 2:36 am

Fixed in 11ba0be.

Using local uninitialized (?) class arrays causes crash

by Accensus » Thu Jun 04, 2020 8:34 am

Tested with both with 4.3.3 and GZDoom g4.4pre-326-g3dfb417f0. Happens on both.

Here's the following code:

Code: Select all

class TreasureImp : DoomImp
{
	override void Die(Actor source, Actor inflictor, int dmgflags)
	{
		class<Ammo> AmmoTypes[3];
		
		// for (int i = 0; i < AmmoTypes.Size(); ++i)
		// {
		// 	AmmoTypes[i] = null;
		// }

		A_DropItem(AmmoTypes[random(0, AmmoTypes.Size() - 1)]);

		Super.Die(source, inflictor, dmgflags);
	}
}
Spawn two TreasureImp actors on top of each other and do mdk. It will crash to desktop. The interesting thing is that it won't happen if you uncomment the for loop that will initialize the array. It will also not happen if you use a string array instead of class<Ammo>. No crash if you only spawn one imp either.

Top