Dungeon Crawl Stone Soup Tracker - DCSS
Viewing Issue Advanced Details
8416 Patches minor have not tried 2014-04-23 03:57 2014-04-24 00:22
floatingatoll Both  
neil All  
normal Both  
resolved 0.15 ancient branch  
0.15-a0-198-g2f4809b done  
none    
none 0.15 ancient branch  
0008416: ouch.cc: add argument checks for function check_your_resists()
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.
? file icon beam_assert_2.patch [^] (811 bytes) 2014-04-23 04:04 [Show Content]
? file icon beam_assert_3.patch [^] (1,266 bytes) 2014-04-23 23:07 [Show Content]
Issue History
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!