View Issue Details

IDProjectCategoryView StatusLast Update
0002275FSSCPSEXPspublic2010-08-17 05:38
ReporterFSF Assigned Toiss_mneur  
PrioritynormalSeveritytweakReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.12 RC4 
Summary0002275: Assert on remove-background-bitmap with faulty index
DescriptionWhen using the remove-background-bitmap SEXP with an index that has no background bitmap assigned to it (i.e. higher index than number of background bitmaps present), FSO gives an assert. A more comprehensive error message would be handy.
Additional InformationTest mission attached, press 1 to produce error.
TagsNo tags attached.

Activities

2010-07-29 15:38

 

background.zip (1,547 bytes)

2010-08-01 01:59

 

mantis_2275.diff (902 bytes)   
Index: code/parse/sexp.cpp
===================================================================
--- code/parse/sexp.cpp	(revision 6340)
+++ code/parse/sexp.cpp	(working copy)
@@ -10260,7 +10260,13 @@
 	int slot = eval_num(n);
 
 	if (slot >= 0) {
-		stars_mark_bitmap_unused( slot );
+		int instances = stars_get_num_bitmaps();
+		if ( instances > slot ) {
+			stars_mark_bitmap_unused( slot );
+		} else {
+			Error(LOCATION, "remove-background-bitmap: slot %d does not exist. Slot must be less than %d.",
+				slot, instances);
+		}
 	}
 }
 
@@ -10343,7 +10349,13 @@
 	int slot = eval_num(n);
 
 	if (slot >= 0) {
-		stars_mark_sun_unused( slot );
+		int instances = stars_get_num_suns();
+		if ( instances > slot ) {
+			stars_mark_sun_unused( slot );
+		} else {
+			Error(LOCATION, "remove-sun-bitmap: slot %d does not exist. Slot must be less than %d.",
+				slot, instances);
+		}
 	}
 }
 
mantis_2275.diff (902 bytes)   

iss_mneur

2010-08-01 01:59

developer   ~0012284

With attached patch, both remove-background-bitmap and remove-sun-bitmap now will issue an Error if an invalid index is passed via the sexp.

iss_mneur

2010-08-17 05:38

developer   ~0012316

Added to trunk in revision 6377

Issue History

Date Modified Username Field Change
2010-07-29 15:38 FSF New Issue
2010-07-29 15:38 FSF File Added: background.zip
2010-08-01 01:59 iss_mneur File Added: mantis_2275.diff
2010-08-01 01:59 iss_mneur Note Added: 0012284
2010-08-01 01:59 iss_mneur Assigned To => iss_mneur
2010-08-01 01:59 iss_mneur Status new => feedback
2010-08-01 01:59 iss_mneur Resolution open => fixed
2010-08-17 05:38 iss_mneur Note Added: 0012316
2010-08-17 05:38 iss_mneur Status feedback => resolved