mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Fixed size_t length comparison with number below 0
This commit is contained in:
parent
d40d4e8d79
commit
db7e785734
1 changed files with 33 additions and 30 deletions
|
@ -80,7 +80,7 @@ class str
|
|||
str();
|
||||
str( const char *text );
|
||||
str( const str& string );
|
||||
str( const str string, size_t start, size_t end );
|
||||
str( const str& string, size_t start, size_t end );
|
||||
str( const char ch );
|
||||
str( const int num );
|
||||
str( const float num );
|
||||
|
@ -245,43 +245,46 @@ inline str::str
|
|||
}
|
||||
|
||||
inline str::str
|
||||
(
|
||||
const str text,
|
||||
(
|
||||
const str& text,
|
||||
size_t start,
|
||||
size_t end
|
||||
) : m_data ( NULL )
|
||||
) : m_data(NULL)
|
||||
|
||||
{
|
||||
{
|
||||
size_t i;
|
||||
size_t len;
|
||||
size_t len;
|
||||
|
||||
if ( end > text.length() )
|
||||
{
|
||||
if (end > text.length())
|
||||
{
|
||||
end = text.length();
|
||||
}
|
||||
|
||||
if ( start > text.length() )
|
||||
{
|
||||
start = text.length();
|
||||
}
|
||||
|
||||
len = end - start;
|
||||
if ( len < 0 )
|
||||
{
|
||||
len = 0;
|
||||
}
|
||||
|
||||
EnsureAlloced ( len + 1 );
|
||||
|
||||
for( i = 0; i < len; i++ )
|
||||
{
|
||||
m_data->data[ i ] = text[ start + i ];
|
||||
}
|
||||
|
||||
m_data->data[ len ] = 0;
|
||||
m_data->len = len;
|
||||
}
|
||||
|
||||
if (start > text.length())
|
||||
{
|
||||
start = text.length();
|
||||
}
|
||||
|
||||
if (end >= start)
|
||||
{
|
||||
len = end - start;
|
||||
}
|
||||
else
|
||||
{
|
||||
len = 0;
|
||||
}
|
||||
|
||||
EnsureAlloced(len + 1);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
m_data->data[i] = text[start + i];
|
||||
}
|
||||
|
||||
m_data->data[len] = 0;
|
||||
m_data->len = len;
|
||||
}
|
||||
|
||||
inline str::str
|
||||
(
|
||||
const char ch
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue