diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index e198c4adc..d8d7e8ba1 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -4167,7 +4167,6 @@ public: spell->source->isToken = 1; spell->source->fresh = 1; spell->source->entersBattlefield = 1; - spell->source->tokCard = spell->source->clone(); if(spell->source->getMTGId() == 0) {//fix missing art: if token creator is put inside ability$!!$ who, then try to get the stored source card if(((MTGCardInstance*)source)->storedSourceCard) @@ -4177,6 +4176,7 @@ public: } } spell->resolve(); + spell->source->tokCard = spell->source->clone(); // tokCard has to be assigned after Spell resolves in order to avoid the pointer is dereferenced. #ISSUE 1040 myToken = spell->source; if(aLivingWeapon) { diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 95f43e5aa..aef84aa26 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -4636,7 +4636,8 @@ int AACloner::resolve() else { clone = _target->tokCard; - clone->data = _target->tokCard;//?wtf + if(clone) // Check if clone is not null to avoid null pointer exception. #ISSUE 1040 + clone->data = _target->tokCard;//?wtf } } else