diff options
author | Richard Soderberg <rsoderberg@gmail.com> | 2014-04-23 17:56:26 -0400 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2014-04-23 17:56:26 -0400 |
commit | 50329fcc3fbb00e2c8ef992fadf36b3b3fb5157a (patch) | |
tree | ed990757b71ec16aaca4d6d652947d0c09930bfd /crawl-ref/source/ouch.cc | |
parent | 70ad64b82ac30a65a044589f0f07ed8555d033c1 (diff) | |
download | crawl-ref-50329fcc3fbb00e2c8ef992fadf36b3b3fb5157a.tar.gz crawl-ref-50329fcc3fbb00e2c8ef992fadf36b3b3fb5157a.zip |
Assert rather than dereference a null in check_your_resists.
Diffstat (limited to 'crawl-ref/source/ouch.cc')
-rw-r--r-- | crawl-ref/source/ouch.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index c5ac75fed4..ba7b513341 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -201,6 +201,10 @@ int check_your_resists(int hurted, beam_type flavour, string source, case BEAM_POISON: if (doEffects) { + // Ensure that we received a valid beam object before proceeding. + // See also melee_attack.cc:_print_resist_messages() which cannot be + // used with this beam type (as it does not provide a valid beam). + ASSERT(beam); int pois = div_rand_round(beam->damage.num * beam->damage.size, 3); pois = 3 + random_range(pois * 2 / 3, pois * 4 / 3); @@ -227,6 +231,10 @@ int check_your_resists(int hurted, beam_type flavour, string source, if (doEffects) { + // Ensure that we received a valid beam object before proceeding. + // See also melee_attack.cc:_print_resist_messages() which cannot be + // used with this beam type (as it does not provide a valid beam). + ASSERT(beam); int pois = div_rand_round(beam->damage.num * beam->damage.size, 3); pois = 3 + random_range(pois * 2 / 3, pois * 4 / 3); |