mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Dive import: reset current_dive in process_imported_dives()
process_imported_dives() might delete the currently selected dives. This could lead to use-after-free problems. Therefore, reset the currently selected dive to the last dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									2775e7e991
								
							
						
					
					
						commit
						a58908df8e
					
				
					 1 changed files with 3 additions and 0 deletions
				
			
		| 
						 | 
					@ -1600,6 +1600,9 @@ void process_imported_dives(struct dive_table *import_table, bool prefer_importe
 | 
				
			||||||
	if (!sequence_changed)
 | 
						if (!sequence_changed)
 | 
				
			||||||
		try_to_renumber(preexisting);
 | 
							try_to_renumber(preexisting);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* We might have deleted the old selected dive.
 | 
				
			||||||
 | 
						 * Choose the newest dive as selected (if any) */
 | 
				
			||||||
 | 
						current_dive = dive_table.nr > 0 ? dive_table.dives[dive_table.nr - 1] : NULL;
 | 
				
			||||||
	mark_divelist_changed(true);
 | 
						mark_divelist_changed(true);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue