mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	pw-cli: fix command parsing after pw_split changes
Don't assume anything about the way the split function maintain the state.
This commit is contained in:
		
							parent
							
								
									0792c690c2
								
							
						
					
					
						commit
						9a90030596
					
				
					 1 changed files with 10 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -118,19 +118,20 @@ struct command {
 | 
			
		|||
static int pw_split_ip(char *str, const char *delimiter, int max_tokens, char *tokens[])
 | 
			
		||||
{
 | 
			
		||||
	const char *state = NULL;
 | 
			
		||||
	char *s;
 | 
			
		||||
	size_t len;
 | 
			
		||||
	char *s, *t;
 | 
			
		||||
	size_t len, l2;
 | 
			
		||||
	int n = 0;
 | 
			
		||||
 | 
			
		||||
	s = (char *)pw_split_walk(str, delimiter, &len, &state);
 | 
			
		||||
	while (s && n + 1 < max_tokens) {
 | 
			
		||||
		t = (char*)pw_split_walk(str, delimiter, &l2, &state);
 | 
			
		||||
		s[len] = '\0';
 | 
			
		||||
		tokens[n++] = s;
 | 
			
		||||
                s = (char*)pw_split_walk(str, delimiter, &len, &state);
 | 
			
		||||
		s = t;
 | 
			
		||||
		len = l2;
 | 
			
		||||
	}
 | 
			
		||||
        if (s) {
 | 
			
		||||
	if (s)
 | 
			
		||||
		tokens[n++] = s;
 | 
			
		||||
        }
 | 
			
		||||
	return n;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue