Permalink
Browse files

CreateProjectile: don't leak the projectile if we change it during a …

…surge

coverity 4449
  • Loading branch information...
1 parent 63b3b73 commit 26e9afb6c65c5326392449b9edbae62a59d6087c @lynxlynxlynx lynxlynxlynx committed Aug 8, 2013
Showing with 2 additions and 0 deletions.
  1. +2 −0 gemrb/core/Scriptable/Scriptable.cpp
@@ -795,6 +795,7 @@ void Scriptable::CreateProjectile(const ieResRef SpellResRef, ieDword tgt, int l
}
}
// we need to refetch the projectile, so the effect queue is created
+ delete pro; // don't leak the original one
pro = spl->GetProjectile(this, SpellHeader, level, LastTargetPos);
pro->SetCaster(GetGlobalID(), level);
break;
@@ -851,6 +852,7 @@ void Scriptable::CreateProjectile(const ieResRef SpellResRef, ieDword tgt, int l
}
}
// we need to refetch the projectile, so the new one is used
+ delete pro; // don't leak the original one
pro = spl->GetProjectile(this, SpellHeader, level, LastTargetPos);
pro->SetCaster(GetGlobalID(), level);
}

0 comments on commit 26e9afb

Please sign in to comment.