mirror of
				https://github.com/luanti-org/luanti.git
				synced 2025-11-04 09:15:29 +01:00 
			
		
		
		
	Settings: Fix crash on exit due to group double-free
This commit is contained in:
		@@ -824,13 +824,21 @@ bool Settings::setDefault(const std::string &name, const std::string &value)
 | 
			
		||||
 | 
			
		||||
bool Settings::setGroup(const std::string &name, Settings *group)
 | 
			
		||||
{
 | 
			
		||||
	return setEntry(name, &group, true, false);
 | 
			
		||||
	// Settings must own the group pointer
 | 
			
		||||
	// avoid double-free by copying the source
 | 
			
		||||
	Settings *copy = new Settings();
 | 
			
		||||
	*copy = *group;
 | 
			
		||||
	return setEntry(name, ©, true, false);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bool Settings::setGroupDefault(const std::string &name, Settings *group)
 | 
			
		||||
{
 | 
			
		||||
	return setEntry(name, &group, true, true);
 | 
			
		||||
	// Settings must own the group pointer
 | 
			
		||||
	// avoid double-free by copying the source
 | 
			
		||||
	Settings *copy = new Settings();
 | 
			
		||||
	*copy = *group;
 | 
			
		||||
	return setEntry(name, ©, true, true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user