Source Code Project Mantis - FSSCP
View Issue Details
0003123FSSCPscriptingpublic2014-10-06 04:072014-11-01 07:08
Reporterm_m 
Assigned Tom_m 
PrioritynormalSeveritymajorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version3.7.1 
Target Version3.7.2Fixed in Version 
Summary0003123: Virtual variables and indexers that return nil break the scripting system
DescriptionIf an ADE_VIRTVAR implementation returns ADE_RETURN_NIL the ade_index_handler will not return that value but will try to call the indexer of the object. If there is none or if it also returns nil the scripting system will raise an error saying that the index could not be found in the referenced type.
To fix this the index handler should always return the value of a called function even if it is nil, the attached patch makes the necessary changes.
Steps To ReproduceHave a ADE_VIRTVAR implementation return ADE_RETURN_NIL. As soon as that VirtVar is accessed a LuaError will be shown claiming that the specified index could not be found.
TagsNo tags attached.
Attached Filespatch lua.cpp.patch (541) 2014-10-06 04:07
http://scp.indiegames.us/mantis/file_download.php?file_id=2579&type=bug
patch 3123.patch (732) 2014-11-01 06:59
http://scp.indiegames.us/mantis/file_download.php?file_id=2604&type=bug

Notes
(0016368)
MageKing17   
2014-10-31 20:21   
Is there any way in which this fix can break existing scripts?
(0016369)
m_m   
2014-11-01 04:17   
There is a very specific case where a VirtVar returns nil and the indexer of the object actually returns the value. I can't think of a script working correctly if it uses this bug.
I don't think this could break existing scripts.
(0016370)
MageKing17   
2014-11-01 07:00   
May as well just get rid of rval altogether (patch attached as per conversation on #scp), but otherwise, consider this reviewed.
(0016371)
m_m   
2014-11-01 07:08   
Fix committed to trunk@11168.

Issue History
2014-10-06 04:07m_mNew Issue
2014-10-06 04:07m_mStatusnew => assigned
2014-10-06 04:07m_mAssigned To => m_m
2014-10-06 04:07m_mFile Added: lua.cpp.patch
2014-10-06 04:08m_mStatusassigned => code review
2014-10-31 20:21MageKing17Note Added: 0016368
2014-11-01 04:17m_mNote Added: 0016369
2014-11-01 06:59MageKing17File Added: 3123.patch
2014-11-01 07:00MageKing17Note Added: 0016370
2014-11-01 07:08m_mChangeset attached => fs2open trunk r11168
2014-11-01 07:08m_mNote Added: 0016371
2014-11-01 07:08m_mStatuscode review => resolved
2014-11-01 07:08m_mResolutionopen => fixed