mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2025-02-21 19:00:56 +00:00
- fixed: FString's 'Strip...' functions could crash on empty strings.
This commit is contained in:
parent
d87b6d6337
commit
696c6af588
1 changed files with 5 additions and 0 deletions
|
@ -583,6 +583,7 @@ void FString::SwapCase ()
|
||||||
void FString::StripLeft ()
|
void FString::StripLeft ()
|
||||||
{
|
{
|
||||||
size_t max = Len(), i, j;
|
size_t max = Len(), i, j;
|
||||||
|
if (max == 0) return;
|
||||||
for (i = 0; i < max; ++i)
|
for (i = 0; i < max; ++i)
|
||||||
{
|
{
|
||||||
if (!isspace(Chars[i]))
|
if (!isspace(Chars[i]))
|
||||||
|
@ -613,6 +614,7 @@ void FString::StripLeft (const FString &charset)
|
||||||
void FString::StripLeft (const char *charset)
|
void FString::StripLeft (const char *charset)
|
||||||
{
|
{
|
||||||
size_t max = Len(), i, j;
|
size_t max = Len(), i, j;
|
||||||
|
if (max == 0) return;
|
||||||
for (i = 0; i < max; ++i)
|
for (i = 0; i < max; ++i)
|
||||||
{
|
{
|
||||||
if (!strchr (charset, Chars[i]))
|
if (!strchr (charset, Chars[i]))
|
||||||
|
@ -665,6 +667,7 @@ void FString::StripRight (const FString &charset)
|
||||||
void FString::StripRight (const char *charset)
|
void FString::StripRight (const char *charset)
|
||||||
{
|
{
|
||||||
size_t max = Len(), i;
|
size_t max = Len(), i;
|
||||||
|
if (max == 0) return;
|
||||||
for (i = max; i-- > 0; )
|
for (i = max; i-- > 0; )
|
||||||
{
|
{
|
||||||
if (!strchr (charset, Chars[i]))
|
if (!strchr (charset, Chars[i]))
|
||||||
|
@ -687,6 +690,7 @@ void FString::StripRight (const char *charset)
|
||||||
void FString::StripLeftRight ()
|
void FString::StripLeftRight ()
|
||||||
{
|
{
|
||||||
size_t max = Len(), i, j, k;
|
size_t max = Len(), i, j, k;
|
||||||
|
if (max == 0) return;
|
||||||
for (i = 0; i < max; ++i)
|
for (i = 0; i < max; ++i)
|
||||||
{
|
{
|
||||||
if (!isspace(Chars[i]))
|
if (!isspace(Chars[i]))
|
||||||
|
@ -723,6 +727,7 @@ void FString::StripLeftRight (const FString &charset)
|
||||||
void FString::StripLeftRight (const char *charset)
|
void FString::StripLeftRight (const char *charset)
|
||||||
{
|
{
|
||||||
size_t max = Len(), i, j, k;
|
size_t max = Len(), i, j, k;
|
||||||
|
if (max == 0) return;
|
||||||
for (i = 0; i < max; ++i)
|
for (i = 0; i < max; ++i)
|
||||||
{
|
{
|
||||||
if (!strchr (charset, Chars[i]))
|
if (!strchr (charset, Chars[i]))
|
||||||
|
|
Loading…
Reference in a new issue