mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	json: improve parse_string
When doing parse_string on a non-string, copy the charaters as they are without escaping.
This commit is contained in:
		
							parent
							
								
									49b17bca22
								
							
						
					
					
						commit
						85cb85d440
					
				
					 1 changed files with 5 additions and 2 deletions
				
			
		| 
						 | 
					@ -283,8 +283,11 @@ static inline bool spa_json_is_string(const char *val, int len)
 | 
				
			||||||
static inline int spa_json_parse_string(const char *val, int len, char *result)
 | 
					static inline int spa_json_parse_string(const char *val, int len, char *result)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const char *p;
 | 
						const char *p;
 | 
				
			||||||
	if (!spa_json_is_string(val, len))
 | 
						if (!spa_json_is_string(val, len)) {
 | 
				
			||||||
		return -1;
 | 
							strncpy(result, val, len);
 | 
				
			||||||
 | 
							result[len] = '\0';
 | 
				
			||||||
 | 
							return 1;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	for (p = val+1; p < val + len-1; p++) {
 | 
						for (p = val+1; p < val + len-1; p++) {
 | 
				
			||||||
		if (*p == '\\') {
 | 
							if (*p == '\\') {
 | 
				
			||||||
			p++;
 | 
								p++;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue