mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	TestParse: prevent crashes
Two CSV imports are failing right now; we shouldn't access uninitialized memory when that happens. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									4c74b15e2f
								
							
						
					
					
						commit
						77ed1b682e
					
				
					 1 changed files with 11 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -202,9 +202,11 @@ void TestParse::testParseHUDC()
 | 
			
		|||
	 * CSV import uses time and date stamps relative to current
 | 
			
		||||
	 * time, thus we need to use a static (random) timestamp
 | 
			
		||||
	 */
 | 
			
		||||
	if (dive_table.nr > 0) {
 | 
			
		||||
		struct dive *dive = dive_table.dives[dive_table.nr - 1];
 | 
			
		||||
		dive->when = 1255152761;
 | 
			
		||||
		dive->dc.when = 1255152761;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TestParse::testParseCompareHUDCOutput()
 | 
			
		||||
| 
						 | 
				
			
			@ -342,15 +344,18 @@ void TestParse::testParseNewFormat()
 | 
			
		|||
		QCOMPARE(parse_seabear_csv_file(file.toUtf8().data(),
 | 
			
		||||
					params, pnr - 1, "csv"), 0);
 | 
			
		||||
 | 
			
		||||
		QCOMPARE(dive_table.nr, 1);
 | 
			
		||||
		/*
 | 
			
		||||
		 * Set artificial but static dive times so the result
 | 
			
		||||
		 * can be compared to saved one.
 | 
			
		||||
		 */
 | 
			
		||||
 | 
			
		||||
		if (dive_table.nr > 0) {
 | 
			
		||||
			dive = dive_table.dives[dive_table.nr - 1];
 | 
			
		||||
			dive->when = 1255152761 + 7200 * i;
 | 
			
		||||
			dive->dc.when = 1255152761 + 7200 * i;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fprintf(stderr, "number of dives %d \n", dive_table.nr);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue