mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 18:55:19 +00:00 
			
		
		
		
	strings.h: Ensure ast_str_buffer(…) returns a 0 terminated string.
If a dynamic string is created with an initial length of 0,
`ast_str_buffer(…)` will return an invalid pointer.
This was a secondary discovery when fixing #65.
(cherry picked from commit 31ab82840b)
			
			
This commit is contained in:
		
				
					committed by
					
						 Asterisk Development Team
						Asterisk Development Team
					
				
			
			
				
	
			
			
			
						parent
						
							1daec58db8
						
					
				
				
					commit
					419feb11bd
				
			| @@ -753,7 +753,10 @@ char * attribute_pure ast_str_buffer(const struct ast_str *buf), | ||||
| 	 * being returned; eventually, it should become truly const | ||||
| 	 * and only be modified via accessor functions | ||||
| 	 */ | ||||
| 	return (char *) buf->__AST_STR_STR; | ||||
| 	if (__builtin_expect(buf->__AST_STR_LEN > 0, 1)) { | ||||
| 		return (char *) buf->__AST_STR_STR; | ||||
| 	} | ||||
| 	return ""; | ||||
| } | ||||
| ) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user