View Issue Details

IDProjectCategoryView StatusLast Update
0002967FSSCPmodular tablespublic2013-12-01 16:06
Reporterniffiwan Assigned ToYarn  
PriorityhighSeveritymajorReproducibilityhave not tried
Status resolvedResolutionfixed 
Product Version3.7.1 
Target Version3.7.2 
Summary0002967: possible negative array index read
DescriptionThis is probably from Yarns persona specific debrief patch (although I haven't confirmed this)
Reported by Coverity: ID 1134041

code/missionui/missiondebrief.cpp
void debrief_award_init()

1. var_tested_neg: Assigning: "Promoted" = a negative value.
 983 Promoted = -1;

....

CID 1134041 (0000001 of 1): Negative array index read (NEGATIVE_RETURNS)5. negative_returns: Using variable "Promoted" as an index to array "Ranks".
1029 if (Ranks[Promoted].promotion_text.find(persona_index) != Ranks[Promoted].promotion_text.end()) {
1030 Badge_stage.text = Medals[Player->stats.m_badge_earned].promotion_text[persona_index];
1031 } else {
1032 Badge_stage.text = Medals[Player->stats.m_badge_earned].promotion_text[-1];
1033 }


(i.e. may manifest if a badge is awarded, but not a promotion)
Steps To Reproduceneeds to be confirmed
TagsNo tags attached.

Activities

Yarn

2013-12-01 01:54

developer   ~0015474

Yes, this is caused by my patch. The problem appears to be in line 1029, where I evidently forgot to change it to read from the Medals array instead of Ranks. The attached patch should fix this.

Yarn

2013-12-01 01:54

developer  

mantis2967.patch (801 bytes)   
Index: code/missionui/missiondebrief.cpp
===================================================================
--- code/missionui/missiondebrief.cpp	(revision 10174)
+++ code/missionui/missiondebrief.cpp	(working copy)
@@ -1026,7 +1026,7 @@
 		int persona_index = debrief_find_persona_index();
 
 		// use persona-specific badge text if it exists; otherwise, use default
-		if (Ranks[Promoted].promotion_text.find(persona_index) != Ranks[Promoted].promotion_text.end()) {
+		if (Medals[Player->stats.m_badge_earned].promotion_text.find(persona_index) != Medals[Player->stats.m_badge_earned].promotion_text.end()) {
 			Badge_stage.text = Medals[Player->stats.m_badge_earned].promotion_text[persona_index];
 		} else {
 			Badge_stage.text = Medals[Player->stats.m_badge_earned].promotion_text[-1];
mantis2967.patch (801 bytes)   

niffiwan

2013-12-01 08:08

developer   ~0015477

Fix committed to trunk@10176.

Goober5000

2013-12-01 16:06

administrator   ~0015479

Crediting Yarn.

Related Changesets

fs2open: trunk r10176

2013-12-01 03:38

niffiwan


Ported: N/A

Details Diff
Fix mantis 2967: use Medals array instead of Ranks (from Yarn) Affected Issues
0002967
mod - /trunk/fs2_open/code/missionui/missiondebrief.cpp Diff File

Issue History

Date Modified Username Field Change
2013-11-30 22:55 niffiwan New Issue
2013-11-30 22:57 niffiwan Description Updated
2013-12-01 01:54 Yarn Note Added: 0015474
2013-12-01 01:54 Yarn File Added: mantis2967.patch
2013-12-01 08:08 niffiwan Changeset attached => fs2open trunk r10176
2013-12-01 08:08 niffiwan Note Added: 0015477
2013-12-01 08:08 niffiwan Status new => resolved
2013-12-01 08:08 niffiwan Resolution open => fixed
2013-12-01 16:06 Goober5000 Note Added: 0015479
2013-12-01 16:06 Goober5000 Assigned To => Yarn