Dungeon Crawl Stone Soup Tracker - DCSS
|
Viewing Issue Advanced Details |
|
ID:
|
Category:
|
Severity:
|
Reproducibility:
|
Date Submitted:
|
Last Update:
|
8416 |
Patches |
minor |
have not tried |
2014-04-23 03:57 |
2014-04-24 00:22 |
|
Reporter:
|
floatingatoll |
Local or Remote:
|
Both |
|
Assigned To:
|
neil |
Operating System:
|
All |
|
Priority:
|
normal |
Console or Tiles:
|
Both |
|
Status:
|
resolved |
Product Branch:
|
0.15 ancient branch |
|
Product Version:
|
0.15-a0-198-g2f4809b |
Resolution:
|
done |
|
Projection:
|
none |
|
|
|
ETA:
|
none |
Fixed in Branch:
|
0.15 ancient branch |
|
|
Summary:
|
0008416: ouch.cc: add argument checks for function check_your_resists() |
Description:
|
ouch.cc function check_your_resists requires a valid 'bolt *beam' when doEffects is true, but does not validate this assumption.
The function itself has two purposes, based on the doEffects value; when false, it calculates an effect; when true, it also applies an effect.
In most cases, applying the effect appears not to require a valid *beam, and everything is fine.
However, the effect BEAM_POISON_ARROW requires a valid *beam as its calculations depend on the damage.num and damage.size properties.
So the attached patch validates that, when doEffect is true, a valid *beam was provided, before trying to dereference it and crashing.
I wasn't able to find any instances of code mis-using this function, either under check_your_resists() or player::beam_resists(), but I'm not familiar with this. |
Steps To Reproduce:
|
|
Additional Information:
|
|
System Description:
|
|
Relationships | |
Attached Files:
|
beam_assert_2.patch [^] (811 bytes) 2014-04-23 04:04 [Show Content] [Hide Content]From 67e6867882a2242a0e9e3f7fa1ade5601299183d Mon Sep 17 00:00:00 2001
From: Richard Soderberg <rsoderberg@gmail.com>
Date: Tue, 22 Apr 2014 16:45:25 -0700
Subject: [PATCH] ouch.cc: check_your_resists needs a valid *bolt when
doEffects is true
---
crawl-ref/source/ouch.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc
index c5ac75f..87ed6a5 100644
--- a/crawl-ref/source/ouch.cc
+++ b/crawl-ref/source/ouch.cc
@@ -124,7 +124,11 @@ int check_your_resists(int hurted, beam_type flavour, string source,
}
if (doEffects)
+ {
+ // Applying effects requires an actual beam object.
+ ASSERT(beam);
_maybe_melt_player_enchantments(flavour, hurted);
+ }
switch (flavour)
{
--
1.8.5.2 (Apple Git-48)
beam_assert_3.patch [^] (1,266 bytes) 2014-04-23 23:07 [Show Content] [Hide Content]diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc
index c5ac75f..ba7b513 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);
|
|
Issue History |
Date Modified |
Username |
Field |
Change |
2014-04-23 03:57 |
floatingatoll |
New Issue |
|
2014-04-23 03:57 |
floatingatoll |
File Added: beam_assert.patch |
|
2014-04-23 04:04 |
floatingatoll |
File Added: beam_assert_2.patch |
|
2014-04-23 04:05 |
Reaver |
File Deleted: beam_assert.patch |
|
2014-04-23 04:05 |
Reaver |
Note Added: 0025888 |
|
2014-04-23 06:25 |
neil |
Note Added: 0025894 |
|
2014-04-23 06:25 |
neil |
Status |
new => resolved |
2014-04-23 06:25 |
neil |
Fixed in Branch |
=> 0.15 development branch |
2014-04-23 06:25 |
neil |
Resolution |
open => done |
2014-04-23 06:25 |
neil |
Assigned To |
=> neil |
2014-04-23 08:05 |
neil |
Note Added: 0025895 |
|
2014-04-23 08:05 |
neil |
Status |
resolved => new |
2014-04-23 08:05 |
neil |
Resolution |
done => reopened |
2014-04-23 08:06 |
neil |
Note Edited: 0025895 |
|
2014-04-23 23:07 |
floatingatoll |
File Added: beam_assert_3.patch |
|
2014-04-23 23:09 |
floatingatoll |
Note Added: 0025898 |
|
2014-04-24 00:22 |
neil |
Note Added: 0025899 |
|
2014-04-24 00:22 |
neil |
Status |
new => resolved |
2014-04-24 00:22 |
neil |
Resolution |
reopened => done |
Notes |
|
(0025888)
|
Reaver
|
2014-04-23 04:05
|
|
Deleted original, broken patch at floatingatoll's request. |
|
|
(0025894)
|
neil
|
2014-04-23 06:25
|
|
Fixed in trunk (0.15-a0-209-g940360b), thanks! I added the assert a few lines earlier |
|
|
(0025895)
|
neil
|
2014-04-23 08:05
(edited on: 2014-04-23 08:06) |
|
Reopening: This assert causes _print_resist_messages to crash every time, because it passes (by default arguments) a null beam and true doEffects. Reverted (0.15-a0-211-gc3d5cf6) for the time being.
|
|
|
(0025898)
|
floatingatoll
|
2014-04-23 23:09
|
|
Revised beam_assert_3.patch adds ASSERT(beam); to BEAM_POISON and BEAM_POISON_ARROW only, along with a comment referencing _print_resist_messages() so that if someone triggers the assertion in the future, they have a fighting chance of knowing why without further research. |
|
|
(0025899)
|
neil
|
2014-04-24 00:22
|
|
Revised patch applied (0.15-a0-218-g50329fc), thanks! |
|