Skip to content

Commit e6e874e

Browse files
authored
bugfix(string): Allow startsWith and endsWith to be called on empty strings (#1979)
1 parent 9573250 commit e6e874e

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Core/GameEngine/Source/Common/System/AsciiString.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,25 +477,25 @@ void AsciiString::format_va(const char* format, va_list args)
477477
// -----------------------------------------------------
478478
Bool AsciiString::startsWith(const char* p) const
479479
{
480-
return ::startsWith(peek(), p);
480+
return m_data && ::startsWith(peek(), p);
481481
}
482482

483483
// -----------------------------------------------------
484484
Bool AsciiString::startsWithNoCase(const char* p) const
485485
{
486-
return ::startsWithNoCase(peek(), p);
486+
return m_data && ::startsWithNoCase(peek(), p);
487487
}
488488

489489
// -----------------------------------------------------
490490
Bool AsciiString::endsWith(const char* p) const
491491
{
492-
return ::endsWith(peek(), p);
492+
return m_data && ::endsWith(peek(), p);
493493
}
494494

495495
// -----------------------------------------------------
496496
Bool AsciiString::endsWithNoCase(const char* p) const
497497
{
498-
return ::endsWithNoCase(peek(), p);
498+
return m_data && ::endsWithNoCase(peek(), p);
499499
}
500500

501501
//-----------------------------------------------------------------------------

Core/GameEngine/Source/Common/System/UnicodeString.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,25 +409,25 @@ void UnicodeString::format_va(const WideChar* format, va_list args)
409409
// -----------------------------------------------------
410410
Bool UnicodeString::startsWith(const WideChar* p) const
411411
{
412-
return ::startsWith(peek(), p);
412+
return m_data && ::startsWith(peek(), p);
413413
}
414414

415415
// -----------------------------------------------------
416416
Bool UnicodeString::startsWithNoCase(const WideChar* p) const
417417
{
418-
return ::startsWithNoCase(peek(), p);
418+
return m_data && ::startsWithNoCase(peek(), p);
419419
}
420420

421421
// -----------------------------------------------------
422422
Bool UnicodeString::endsWith(const WideChar* p) const
423423
{
424-
return ::endsWith(peek(), p);
424+
return m_data && ::endsWith(peek(), p);
425425
}
426426

427427
// -----------------------------------------------------
428428
Bool UnicodeString::endsWithNoCase(const WideChar* p) const
429429
{
430-
return ::endsWithNoCase(peek(), p);
430+
return m_data && ::endsWithNoCase(peek(), p);
431431
}
432432

433433
//-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)