be safe while doing copy to EntityClass::flagnames
This commit is contained in:
parent
1a12e3b226
commit
1c3300d4bb
|
|
@ -264,8 +264,8 @@ inline EntityClass* Eclass_Alloc(){
|
|||
e->has_angles = false;
|
||||
e->has_angles_key = false;
|
||||
e->has_direction_key = false;
|
||||
memset( e->flagnames, 0, MAX_FLAGS * 32 );
|
||||
memset( e->flagAttributes, 0, MAX_FLAGS * sizeof( EntityClassAttribute* ) );
|
||||
memset( e->flagnames, 0, sizeof( e->flagnames ) );
|
||||
memset( e->flagAttributes, 0, sizeof( e->flagAttributes ) );
|
||||
|
||||
e->maxs = Vector3( -1,-1,-1 );
|
||||
e->mins = Vector3( 1, 1, 1 );
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ EntityClass *Eclass_InitFromText( const char *text ){
|
|||
if ( !p ) {
|
||||
break;
|
||||
}
|
||||
strcpy( e->flagnames[i], Get_COM_Token() );
|
||||
strncpy( e->flagnames[i], Get_COM_Token(), std::size( e->flagnames[i] ) - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ void EntityClassFGD_parseClass( Tokeniser& tokeniser, bool fixedsize, bool isBas
|
|||
ASSERT_MESSAGE( EntityClassFGD_parseToken( tokeniser, ":" ), PARSE_ERROR );
|
||||
|
||||
const char* name = tokeniser.getToken();
|
||||
strcpy( entityClass->flagnames[bit], name );
|
||||
strncpy( entityClass->flagnames[bit], name, std::size( entityClass->flagnames[bit] ) - 1 );
|
||||
EntityClassAttribute *attribute = &EntityClass_insertAttribute( *entityClass, name, EntityClassAttribute( "flag", name ) ).second;
|
||||
entityClass->flagAttributes[bit] = attribute;
|
||||
{
|
||||
|
|
@ -656,7 +656,7 @@ void EntityClassFGD_resolveInheritance( EntityClass* derivedClass ){
|
|||
|
||||
for( size_t flag = 0; flag < MAX_FLAGS; ++flag ){
|
||||
if( !string_empty( parentClass->flagnames[flag] ) && string_empty( derivedClass->flagnames[flag] ) ){
|
||||
strcpy( derivedClass->flagnames[flag], parentClass->flagnames[flag] );
|
||||
strncpy( derivedClass->flagnames[flag], parentClass->flagnames[flag], std::size( derivedClass->flagnames[flag] ) - 1 );
|
||||
derivedClass->flagAttributes[flag] = parentClass->flagAttributes[flag];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ public:
|
|||
std::size_t bit = atoi( element.attribute( "bit" ) );
|
||||
ASSERT_MESSAGE( bit < MAX_FLAGS, "invalid flag bit" );
|
||||
ASSERT_MESSAGE( string_empty( entityClass->flagnames[bit] ), "non-unique flag bit" );
|
||||
strcpy( entityClass->flagnames[bit], key );
|
||||
strncpy( entityClass->flagnames[bit], key, std::size( entityClass->flagnames[bit] ) - 1 );
|
||||
entityClass->flagAttributes[bit] = m_attribute;
|
||||
}
|
||||
else if( entityClass->fixedsize && string_equal( type, "model" ) ){
|
||||
|
|
|
|||
|
|
@ -856,7 +856,7 @@ void SpawnFlags_setEntityClass( EntityClass* eclass ){
|
|||
// do a first pass to count the spawn flags, don't touch the widgets, we don't know in what state they are
|
||||
for ( int i = 0; i < MAX_FLAGS; i++ )
|
||||
{
|
||||
if ( eclass->flagnames[i][0] != 0 && strcmp( eclass->flagnames[i],"-" ) ) {
|
||||
if ( eclass->flagnames[i][0] != 0 && strcmp( eclass->flagnames[i], "-" ) ) {
|
||||
spawn_table[g_spawnflag_count++] = i;
|
||||
}
|
||||
// hide all boxes
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user