mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	cmd_input: cleanup around current_input_config
- Restore old one if we weren't part of a block (should be NULL anyway) - Check current_input_config got properly allocated - free temporary current_input_config when done using it
This commit is contained in:
		
							parent
							
								
									afca73b6fc
								
							
						
					
					
						commit
						28b8ea9f1e
					
				
					 1 changed files with 6 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -24,7 +24,11 @@ struct cmd_results *cmd_input(int argc, char **argv) {
 | 
			
		|||
	char **argv_new = argv+2;
 | 
			
		||||
 | 
			
		||||
	struct cmd_results *res;
 | 
			
		||||
	struct input_config *old_input_config = current_input_config;
 | 
			
		||||
	current_input_config = new_input_config(argv[0]);
 | 
			
		||||
	if (!current_input_config) {
 | 
			
		||||
		return cmd_results_new(CMD_FAILURE, NULL, "Couldn't allocate config");
 | 
			
		||||
	}
 | 
			
		||||
	if (strcasecmp("accel_profile", argv[1]) == 0) {
 | 
			
		||||
		res = input_cmd_accel_profile(argc_new, argv_new);
 | 
			
		||||
	} else if (strcasecmp("click_method", argv[1]) == 0) {
 | 
			
		||||
| 
						 | 
				
			
			@ -60,6 +64,7 @@ struct cmd_results *cmd_input(int argc, char **argv) {
 | 
			
		|||
	} else {
 | 
			
		||||
		res = cmd_results_new(CMD_INVALID, "input <device>", "Unknown command %s", argv[1]);
 | 
			
		||||
	}
 | 
			
		||||
	current_input_config = NULL;
 | 
			
		||||
	free_input_config(current_input_config);
 | 
			
		||||
	current_input_config = old_input_config;
 | 
			
		||||
	return res;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue