'Free heap modifed' after deleting custom class containing Sprite

I’m using Cocos2d-x 3.16 on VS2013.

I made a custom class with sprites in it,
which looks like this

struct Weapon
{
private:
public:
 Weapon();
 ~Weapon();
 Sprite *base, *barrel, *muzzleFlash;
 Sprite *lasMuzzle, *lasBody, *lasImpact;
 //other variables (int, float)
};

class Drone
{
private:
 Node* scene;
 Sprite *Chassis, *Turret, *Shield, *boostAnim;
 cocos2d::MotionStreak* MS;
 std::vector<Weapon*> Weapons; //struct defined above
 //variables and functions below
public:
 ...
 //variables and functions below
};

After deleting drone object, error occurs.

HEAP: Free Heap block XXXXXXXX modified at XXXXXXXX after it was freed

and when I try on the android device, this error occurs.

fatal signal 11 (sigsegv) code 2, fault addr (address)

destructors of Weapon and Drone,

Weapon::~Weapon()
{
 if (muzzleFlash != nullptr)
 {
  muzzleFlash->removeFromParentAndCleanup(true);
 }
 if (barrel != nullptr)
 {
  barrel->removeFromParentAndCleanup(true);
 }
 if (lasMuzzle != nullptr)
 {
  lasMuzzle->removeFromParentAndCleanup(true);
 }
 if (lasBody != nullptr)
 {
  lasBody->removeFromParentAndCleanup(true);
 }
 if (lasImpact != nullptr)
 {
  lasImpact->removeFromParentAndCleanup(true);
 }
 if (base != nullptr)
 {
  base->removeFromParentAndCleanup(true);
 }
}
Drone::~Drone()
{
 for (int loop = 0; loop < Weapons.size(); loop++)
 {
  delete Weapons[loop];
 }
 Weapons.clear();

 if (Shield != nullptr)
 {
  Shield->removeAllChildrenWithCleanup(true);
  Shield->removeFromParentAndCleanup(true);
 }
 if (boostAnim != nullptr)
 {
  boostAnim->removeAllChildrenWithCleanup(true);
  boostAnim->removeFromParentAndCleanup(true);
 }
 if (Turret != nullptr)
 {
  Turret->removeAllChildrenWithCleanup(true);
  Turret->removeFromParentAndCleanup(true);
 }
 if (MS != nullptr)
 {
  MS->removeFromParentAndCleanup(true);
 }
 if (Chassis != nullptr)
 {
  Chassis->removeAllChildrenWithCleanup(true);
  Chassis->removeFromParentAndCleanup(true);
 }
}

I stored objects in std::list, delete like,

for (auto loop = vRobots.begin(); loop != vRobots.end();)
{
	auto bot = *loop;
	if (bot->isDestroyed)
	{
		vRobots.erase(loop++);
		if (bot == EnemyBot)
		{
			endBattle(true);
			return;
		}
		delete bot;
	}
	else
	++loop;
}

Strange thing is, there is Projectile class which is also a custom class,
and deleting projectiles object doesn’t cause problem.

Projectile::~Projectile()
{
	delete fHit; //Factory Function. nothing special.
	image->removeFromParentAndCleanup(true); //the only sprite in the class.
	//CCLOG("Projectile Destruct");
}

Maybe it’s not a good idea to make a class like these?
or maybe I’m blind and missed something? There aren’t any other codes than those really.
I have no idea.

Why Weapon is a struct but not a class? In cocos2d-x, always construct game objects inherited from cocos2d::Ref so their retain counts could be easily maintained by the underlying autorelease mechanism:

class Weapon : cocos2d::Ref
class Drone : cocos2d::Ref

Hence containers of cocos2d::Ref objects should be cocos2d::Vector here:

cocos2d::Vector<Weapon*> Weapons;

In such manner you don’t need to clear the list of weapons in the destructor

For those Sprite*, MotionStreak*, or any objects that are inheriting from cocos2d::Node, do not retain or remove them manually as the best practice, and let their parent nodes as the only object to manage their retain counts; on destruction of the root scene, the leaf nodes would be subsequently destructed along the tree of the scene graph.

But Drone class doesn’t inherit Ref either.
Drone Class merely has Sprites in them.
Well, yes I should change that struct to class anyway.

I mean both Drone and Weapon should be inherited from Ref

I followed this one to make my own custom class. Is this not a good practice?

He is just throwing out some pseudo codes so that’s not a sample you should follow.

I made my classes inherit Node,
didn’t solve anything.
still same heap error, during CCRenderer