mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	commands: Fix memory allocation in assign
Also use the safer snprintf since we just computed the size. Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
		
							parent
							
								
									43483d8fee
								
							
						
					
					
						commit
						449617f104
					
				
					 1 changed files with 3 additions and 3 deletions
				
			
		| 
						 | 
					@ -177,10 +177,10 @@ static struct cmd_results *cmd_assign(int argc, char **argv) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	char *movecmd = "move container to workspace ";
 | 
						char *movecmd = "move container to workspace ";
 | 
				
			||||||
	int arglen = strlen(*argv);
 | 
						int arglen = strlen(movecmd) + strlen(*argv) + 1;
 | 
				
			||||||
	char *cmdlist = calloc(1, sizeof(movecmd) + arglen);
 | 
						char *cmdlist = calloc(1, arglen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sprintf(cmdlist, "%s%s", movecmd, *argv);
 | 
						snprintf(cmdlist, arglen, "%s%s", movecmd, *argv);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct criteria *crit = malloc(sizeof(struct criteria));
 | 
						struct criteria *crit = malloc(sizeof(struct criteria));
 | 
				
			||||||
	crit->crit_raw = strdup(criteria);
 | 
						crit->crit_raw = strdup(criteria);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue