mirror of
				https://github.com/NoelFB/blah.git
				synced 2025-11-04 01:41:34 +08:00 
			
		
		
		
	catching null strings in Str::starts_with/ends_with
This commit is contained in:
		@ -262,8 +262,11 @@ Str& Str::trim()
 | 
			
		||||
 | 
			
		||||
bool Str::starts_with(const char* str, bool ignoreCase) const
 | 
			
		||||
{
 | 
			
		||||
	if (str == nullptr)
 | 
			
		||||
		return m_length == 0;
 | 
			
		||||
 | 
			
		||||
	int len = (int)strlen(str);
 | 
			
		||||
	if (len > m_length || len <= 0)
 | 
			
		||||
	if (len > m_length)
 | 
			
		||||
		return false;
 | 
			
		||||
 | 
			
		||||
	const char* a = data();
 | 
			
		||||
@ -320,6 +323,9 @@ bool Str::contains(const char* str, bool ignoreCase) const
 | 
			
		||||
 | 
			
		||||
bool Str::ends_with(const char* str, bool ignoreCase) const
 | 
			
		||||
{
 | 
			
		||||
	if (str == nullptr)
 | 
			
		||||
		return m_length == 0;
 | 
			
		||||
 | 
			
		||||
	int len = (int)strlen(str);
 | 
			
		||||
	if (len > m_length || len <= 0)
 | 
			
		||||
		return false;
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user